HDU 1393 Weird Clock
来源:互联网 发布:淘宝上比较好的女鞋店 编辑:程序博客网 时间:2024/05/23 23:58
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.
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.
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 10 0
Sample Output
1
题意:有一个只有分针的表,给出针的初始位置,然后后面是倍数n,每次顺时针旋转当前点数的n倍,最后求转到0需要多少步。如果转不回去就输出Impossible。
直接就照他的走,反正步数不会太多,顶多60步,转到初始位置说明是个死循环,则不可能。
#include<stdio.h>int main(){ int n,d,i,j,N; while(~scanf("%d%d",&n,&d)&&n+d) { N=n; j=0; for(i=0; i<60; i++) { if(n==0) { printf("%d\n",j); break; } j++; n+=n*d; n=n%60; } if(n!=0) { printf("Impossible\n"); } } return 0;}
2 0
- HDU 1393 Weird Clock
- HDU 1393 Weird Clock
- hdu 1393 Weird Clock
- hdu 1393 Weird Clock
- HDU 1393 Weird Clock
- 杭电 HDU ACM 1393 Weird Clock
- HDU 1393 Weird Clock (模拟)
- HDOJ 1393 Weird Clock
- HDU——1393Weird Clock(水题,注意题意)
- hdoj.1393 Weird Clock 20140825
- Weird Clock
- Weird Clock
- zoj 1476 Weird Clock
- HDU1393:Weird Clock
- hdu1393 Weird Clock
- HOJ 1006 Weird clock
- HOJ 1006 Weird Clock
- 1393.Weird Clock
- 递归逆序打印字符串
- webx 容器初始化
- Android Studio 多环境打包(测试,开发,生产)
- 2016.8.14
- html5 audio,video 操作方法
- HDU 1393 Weird Clock
- 实现链表的反转
- 面向对象的三大特征
- Light OJ:1104 Birthday Paradox(数学概率+思维)
- 每天00:00,MySQL定时弹出一个taskeng.exe
- Ubuntu下基本开发环境配置
- HDU 5832 A water problem
- 浅析AMBA规范以及AMBA 5 AHB接口和AMBA 3 APB接口
- 文件夹隐藏不被搜索