FZU - 2147 A-B Game(找规律)

Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u

 Status

Description

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

组队后的第一场比赛,能有幸看到大神们是怎样做题的,各种技巧,怎样生成例子,怎样算时间等等。突然发现以前自己的比赛都是在凭感觉打代码,离开模板自己很多东西打不出来,讨论时也各种用错词,基本功课真应该做好,自己要学的东西还很多。不想拖队伍的后腿,渣油吧xc。给我一个坚定的眼神害羞

这题的重点是要找出A%x(1<=x<=A-1)的最大值。打出前100个数可以找到规律。

就是(A+1)/ 2-1。然后就没有然后了。。

2 0
3 1
4 1
5 2
6 2
7 3
8 3
9 4
10 4
11 5
12 5
13 6
14 6
15 7
16 7
17 8
18 8
19 9
20 9
21 10
22 10
23 11
24 11
25 12
26 12
27 13
28 13
29 14
30 14
31 15
32 15
33 16
34 16
35 17
36 17
37 18
38 18
39 19
40 19
41 20
42 20
43 21
44 21
45 22
46 22
47 23
48 23
49 24
50 24
51 25
52 25
53 26
54 26
55 27
56 27
57 28
58 28
59 29
60 29
61 30
62 30
63 31
64 31
65 32
66 32
67 33
68 33
69 34
70 34
71 35
72 35
73 36
74 36
75 37
76 37
77 38
78 38
79 39
80 39
81 40
82 40
83 41
84 41
85 42
86 42
87 43
88 43
89 44
90 44
91 45
92 45
93 46
94 46
95 47
96 47
97 48
98 48
99 49
100 49
请按任意键继续. . .

#include<iostream>
#include<cstring>
using namespace std;
#define LL long long 
int main()
{
	LL A, B;
	int casen;
	cin >> casen;
	for (int cas = 1; cas <= casen;cas++)
	{
		int cnt = 0;
		cin >> A >> B;
		while (A > B)
		{
			A = A - ((A + 1) / 2 - 1);
			cnt++;
		}
		cout << "Case "<<cas<<": "<<cnt << endl;
	}
}



  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

这波lucio来全学了

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值