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 5387(Clock)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5387 比较水的一道题目,也是自己单翘的第一道题目吧,题意就是找到给定时间时钟三个指针之间的夹角, 需要 ...
- HDOJ(HDU) 2178 猜数字(题意有点难理解、、、)
Problem Description A有1数m,B来猜.B每猜一次,A就说"太大","太小"或"对了" . 问B猜n次可以猜到的最大数. ...
- 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^ ...
- 人体时钟hone hone clock
摘要:一个由日本人设计的有意思的Flash时钟:人体时钟 hone hone clock .安装很简单,直接js导入即可,包括两种样式:透明背景和白色背景. 很可爱的一个设计,实现后效果如下: 使用方 ...
- HDU4523+简单
题意很简单. 一次最多多切出一条边! 其余的就没什么好说的了 import java.util.*; import java.math.*; public class Main{ public sta ...
随机推荐
- long long or int
long long or int 很多时候long long爆空间,int有时又不够 . 在算乘法的时候,要保证乘出来的中间项也不爆long long
- 我们为什么要学习 Spring Boot
现在貌似大家都知道 Spring Boot 很火了,做 Java 的不知道 Spring Boot 的都已经 Out 了,但是又有多少人是跟风学习的呢?今天我们就来说一下为什么要学习 Spring B ...
- racket 学习笔记
length: (define (my-length lst) (if (empty? lst) 0 (+ (my-length (rest lst)) 1))) map: (define (my-m ...
- 细解javascript中的this关键字
JavaScript函数中的this指向并不是在函数定义的时候确定的,而是在调用的时候确定的.换句话说,函数的调用方式决定了this指向. 一. 全局上下文 在函数外部,无论是否在严格模式下,this ...
- 暴力破解ZIP文件密码
Python 的标准库提供了 ZIP 文件的提取压缩模块 zipfile,现在让我们试着用这个模块,暴力破解出加密的 ZIP 文件!我们可以用 extractall()这个函数抽取文件,密码正确则返回 ...
- convert时间格式转换参数表
本文摘自:http://blog.csdn.net/zc19820620/article/details/2043829 CONVERT (data_type[(length)], expressio ...
- android studio 代码模板
作者:韩梦飞沙 Author:han_meng_fei_sha 邮箱:313134555@qq.com E-mail: 313134555 @qq.com android studio 代码模板 an ...
- BZOJ.3620.似乎在梦中见过的样子(KMP)
题目链接 /* 896kb 6816ms A+B+A是KMP的形式,于是固定左端点,对于每个位置i,若fail[i]所能到的点k中(k=fail[fail[fail[...]]]),有满足len(l~ ...
- Linux学习笔记15—RPM包的安装OR源码包的安装
RPM安装命令1. 安装一个rpm包rpm –ivh 包名“-i” : 安装的意思“-v” : 可视化“-h” : 显示安装进度另外在安装一个rpm包时常用的附带参数有:--force : 强制安装, ...
- 【转】浅谈分布式服务协调技术 Zookeeper
非常好介绍Zookeeper的文章, Google的三篇论文影响了很多很多人,也影响了很多很多系统.这三篇论文一直是分布式领域传阅的经典.根据MapReduce,于是我们有了Hadoop:根据GFS, ...