码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-04-13 09:32:38      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:

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;
	}
}



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

标签:

原文地址:http://blog.csdn.net/qq_18738333/article/details/45016135

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!