FZU 2147
来源:互联网 发布:php的exec函数 编辑:程序博客网 时间:2024/05/17 23:39
题目
Fat brother and Maze are playing a kind of special (hentai) game by two integers A and B. First Fat brother write an integer A on a white paper and then Maze start to change this integer. Every time Maze can select an integer x between 1 and A-1 then change A into A-(A%x). The game ends when this integer is less than or equals to B. Here is the problem, at least how many times Maze needs to perform to end this special (hentai) game.
Input
The first line of the date is an integer T, which is the number of the text cases.
Then T cases follow, each case contains two integers A and B described above.
1 <= T <=100, 2 <= B < A < 100861008610086
Output
For each case, output the case number first, and then output an integer describes the number of times Maze needs to perform. See the sample input and output for more details.
Sample Input
2
5 3
10086 110
Sample Output
Case 1: 1
Case 2: 7
水题,给你两个数a ,b 求找一个(1-a)数n,让a-a%n 求多少次操作后 a < b;
也就是让a%n尽可能大,也就是n==(a/2)+1;
上代码:
JAVA //记得数据范围
package 福建_A_B_Game;import java.math.BigInteger;import java.util.Scanner;public class Main { public static void main(String args[]) { Scanner cin=new Scanner(System.in); int t; t=cin.nextInt(); int tt=0; while(t>0) { t--;tt++; BigInteger a,b,c; a=cin.nextBigInteger(); b=cin.nextBigInteger(); int ans=0; while(a.compareTo(b)>=0) { a=a.mod((a.divide(BigInteger.valueOf(2)).add(BigInteger.ONE))); ans++; } System.out.println("Case "+tt+": "+ans); } }}
- FZU 2147
- FZU 2147
- FZU 2147(找规律)
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- 数据结构实验之栈二:一般算术表达式转换成后缀式
- SQLite数据库
- ARM之LED驱动
- 封装概念
- E
- FZU 2147
- UVa455-Periodic Strings
- pyqt获取组合键
- 【HDU 1102】Constructing Roads(最小生成树)
- UVa1225-Digit Counting
- 僵尸、孤儿、守护进程
- jQuery遍历之children()方法
- 2017 暑假艾教集训 day3
- UVa1583-Digit Generator