Uva 10550 Combination Lock

Sample Input
0 30 0 30
5 35 5 35
0 20 0 20
7 27 7 27
0 10 0 10
9 19 9 19
0 0 0 0
Sample Output
1350
1350
1620
1620
1890
1890
===========================================================================================================
super simple等级
常量声明 R : 一圈有多少个刻度(这里为40)
首先我总结了 从刻度A到刻度B顺时针转动的规律 :
如果A >= B 那么直接取他们的差就是他们相差的刻度, 如果A<B 就是A-B+R 才是他们相差的刻度;
那么逆时针呢?
很简单,把从A到B 逆时针转动 转换成 从B到A顺时针 ,那么就只要考虑顺时针这一种情况了
#include<stdio.h>
#define R 40 int degree( int a ,int b){
if( a> b) return (a-b)*;
else return (a-b+R)*;
}
int main(){
int a, b ,c,d ,re = ;
while( scanf("%d%d%d%d",&a,&b,&c,&d) && !(!a && !b && !c && !d)){
re = ;
re+= degree(a,b);
re+= degree(c,b);
re+= degree(c,d);
printf("%d\n",re);
}
return ;
}
有更好的想法? 欢迎邮件 ethanxlj@foxmail.com
Uva 10550 Combination Lock的更多相关文章
- Combination Lock
时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Finally, you come to the interview room. You know that a Micr ...
- hihocoder #1058 Combination Lock
传送门 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Finally, you come to the interview room. You know that a ...
- 贪心 Codeforces Round #301 (Div. 2) A. Combination Lock
题目传送门 /* 贪心水题:累加到目标数字的距离,两头找取最小值 */ #include <cstdio> #include <iostream> #include <a ...
- Codeforces Round #301 (Div. 2) A. Combination Lock 暴力
A. Combination Lock Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/540/p ...
- Hiho----微软笔试题《Combination Lock》
Combination Lock 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Finally, you come to the interview room. You ...
- CF #301 A :Combination Lock(简单循环)
A :Combination Lock 题意就是有一个密码箱,密码是n位数,现在有一个当前箱子上显示密码A和正确密码B,求有A到B一共至少需要滚动几次: 简单循环:
- hihocoder-第六十一周 Combination Lock
题目1 : Combination Lock 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Finally, you come to the interview roo ...
- A - Combination Lock
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description Scroog ...
- HDU 3104 Combination Lock(数学题)
题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=3104 Problem Description A combination lock consists ...
随机推荐
- 应用在安卓和ios端APP的证件识别
移动端证件识别智能图文处理,是利用OCR识别技术,通过手机拍摄身份证图像或者从手机相册中加载证件图像,过滤身份证的背景底纹干扰,自动分析证件各文字进行字符切分.识别,最后将识别结果按姓名.地址.民族. ...
- ssm框架下web项目,web.xml配置文件的作用
1. web.xml中配置了CharacterEncodingFilter,配置这个是拦截所有的资源并设置好编号格式. encoding设置成utf-8就相当于request.setCharacter ...
- c#基础知识索引器
代码 ]); }} 在这里我们看到,无非是实现了一个泛型算法 等同于 Ontology List<string> lit=new List<string>(); lis. ...
- [转载] ETL和Kettle
http://tech.ccidnet.com/art/1105/20080407/1411567_1.html http://blog.csdn.net/cissyring/article/deta ...
- linux操作系统基础篇(九)
shell脚本的运算符与流程控制 1.运算符 1.1 算术运算符 + - * / % [root@MiWiFi-R3-srv ~]# echo $[3+1]4 1.2 关系操作 与(())连用 < ...
- angular 使用概术
框架技术细节说明 must 该文档详细说明了基于Angular的机制及关键技术. 目录: - 路由机制 - 通过路由来切分页面模块 - Lazyload机制 - 指令 - 程序bootstrap - ...
- GameObject类及相关API
GameObject.Find(String name):查找一个名为name的游戏物体,并返回这个游戏物体,找不到返回null.(不到万不得已,不要在Update()中使用,建议在Start()中使 ...
- impala基础
impala: 查询impala表时一定要加库名使用级联删除带有表的数据库:DROP database name cascade; insert插入的两种方式: 1. insert into empl ...
- LayoutInflater (转)
在实际开发中LayoutInflater这个类还是非常有用的,它的作用类似于findViewById().不同点是LayoutInflater是用来找res/layout/下的xml布局文件,并且实例 ...
- AndroidStudio cannot resolve symbol 解决办法 清楚缓存
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android=&qu ...