HDOJ 1393 Weird Clock(明白题意就简单了)
Problem Description
A weird clock marked from 0 to 59 has only a minute hand. It won’t move until a special coin is thrown into its box. There are different kinds of coins as your options. However once you make your choice, you cannot use any other kind. There are infinite number of coins of each kind, each marked with a number d ( 1 <= d <= 1000 ), meaning that this coin will make the minute hand move d times clockwise the current time. For example, if the current time is 45, and d = 2. Then the minute hand will move clockwise 90 minutes and will be pointing to 15.
Now you are given the initial time s ( 1 <= s <= 59 ) and the coin’s type d. Write a program to find the minimum number of d-coins needed to turn the minute hand back to 0.
Input
There are several tests. Each test occupies a line containing two positive integers s and d.
The input is finished by a line containing 0 0.
Output
For each test print in a single line the minimum number of coins needed. If it is impossible to turn the hand back to 0, output “Impossible”.
Sample Input
30 1
0 0
Sample Output
1
明白题意之后就简单了,
思路:一个钟面只有一根分针。对于一个数字d,把钟面上的分针指向的时间s往后拨s的d倍。问给定d,重复这样的操作多少次能回拨到0。若不能则输出Impossible。
注意:此处的s是不断更新的!!!!!!!!!!!
因为钟面只有60分钟,所以最多不会超过60次,直接暴力就可。
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int s= sc.nextInt();
int d = sc.nextInt();
if(s==0&&d==0){
return ;
}
int num=s;
for(int i=1;i<65;i++){
num = (num+(num*d))%60;
if(num==0){
System.out.println(i);
break;
}
if(i>63){
System.out.println("Impossible");
break;
}
}
}
}
}
HDOJ 1393 Weird Clock(明白题意就简单了)的更多相关文章
- HDOJ 1393 Weird Clock(明确题意就简单了)
Problem Description A weird clock marked from 0 to 59 has only a minute hand. It won't move until a ...
- HDU 1393 Weird Clock (英语,纪念题)
这题简单,只要看懂题目就好,坑爹的是我的英语水平太差了,wa了n次,所以 仅此纪念 一下. //坑爹的英语题目,注意重点:move d times clockwise the current time ...
- HDOJ(HDU) 2178 猜数字(题意有点难理解、、、)
Problem Description A有1数m,B来猜.B每猜一次,A就说"太大","太小"或"对了" . 问B猜n次可以猜到的最大数. ...
- hdoj 5387(Clock)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5387 比较水的一道题目,也是自己单翘的第一道题目吧,题意就是找到给定时间时钟三个指针之间的夹角, 需要 ...
- HDOJ 1196 Lowest Bit(二进制相关的简单题)
Problem Description Given an positive integer A (1 <= A <= 100), output the lowest bit of A. F ...
- HDU——1393Weird Clock(水题,注意题意)
Weird Clock Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- 【HDOJ】3205 Factorization
题意很简单.就是求x^k-1的因式分解.显然x-1必然是其中之一(x=1, x^k-1=0).假设k=mp. 则x^k = (x^p)^m, 同理x^p-1必然是其中之一,即x^p的所有因式一定是x^ ...
- 线段树+树状数组+贪心 HDOJ 5338 ZZX and Permutations
题目传送门 /* 题意:不懂... 线段树+树状数组+贪心:贪心从第一位开始枚举,一个数可以是循环节的末尾或者在循环节中,循环节(循环节内部是后面的换到前面,最前面的换到最后面).线段树维护最大值,树 ...
- IDA的脚本IDC的一个简单使用
目的:主要是想学习一下IDA的IDC的脚本的使用.这里做了一个小的测试. 这里使用的是VS2015Community来生成文件的. 一.编写测试程序: 这里先生成我们的目标数据. 然后编写测试程序.得 ...
随机推荐
- 坑爹火狐浏览器会记录表单数据,导致服务器控件点击事件出bug
解决方案:在form表单加入 autocomplete="off".
- 集成对象和 JSON
想象一下,如果 NSDictionary,NSArray,NSString 呾 NSData 都提供方法 相亏转换 JSON 数据,返样丌径好举? 嗯,等等 – 我们正在使用 Objective-C, ...
- Android 出现警告Exported service does not require permission
在配置Android清单文件的时候,配置service,或者activity,或者receive的时候,出现Exported service does not require permission警告 ...
- Hibernate的fetch
hibernate抓取策略fetch具体解释一.hibernate抓取策略(单端代理的批量抓取fetch=select(默认)/join)測试用例:Student student = (Student ...
- angularjs手动解析表达式($parse)
<!DOCTYPE html> <html lang="zh-CN" ng-app="app"> <head> <me ...
- linux 网络状态工具ss命令
ss命令用于显示socket状态. 他可以显示PACKET sockets, TCP sockets, UDP sockets, DCCP sockets, RAW sockets, Unix dom ...
- 【转】解决警告 warning: directory not found for option
转:http://blog.sina.com.cn/s/blog_6f72ff900101es6x.html 解决方法: 选择项目名称----->Targets----->Build Se ...
- 软键盘 输入法管理器 InputMethodManager
基本介绍 软键盘的显示原理 软键盘其实是一个Dialog.InputMethodService为我们的输入法创建了一个Dialog,并且对某些参数进行了设置,使之能够在底部或者全屏显示.当我们点击输 ...
- ShareSDK 社会化分享 集成步骤
第一步 :获取ShareSDK 官网:http://www.mob.com 完整的集成文档:http://wiki.mob.com/android-sharesdk%E5%AE%8C%E6%95%B4 ...
- codevs 4827 妹子
/* 赤裸裸的数学题 各种整体+插空 所以嘛 学好数学还是很重要的 ans=(n-1)!*(m-1)!*(2+(n-2)(n-1)) */ #include<iostream> #incl ...