A-B Game
Time Limit: 1000MS |
|
Memory Limit: 32768KB |
|
64bit IO Format: %i64d &%i64u |
Submit Status
Description
Fat brother and Maze is playing a kind of special (hentai) game by, integers a and B. First Fat brother write an integer A in 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 to A A-(a%x). The game ends when this integer is less than or equals to B. Here are the problem, at least-many times Maze needs to perform to-end this special (hentai) game.
Input
The first line of the date is a integer T, which is the number of the text cases.
Then T cases follow, each case contains the 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 a integer describes the number of times Maze needs to perfor M. See the sample, input and output for more details.
Sample Input
2
5 3
10086 110
Sample Output
Case 1:1
Case 2:7
team after the first game, can be fortunate to see how the great gods do the problem, various skills, how to generate examples, how to calculate time and so on. Suddenly found that their own game is in the sense of playing code, leaving the template himself a lot of things can not be played out, the discussion is also a variety of use of the wrong words, the basic lessons should be done, I have to learn a lot of things. Do not want to drag the hind legs of the team, residue Oil bar xc. Give me a firm look in my eyes .
The point of this question is to find out the maximum value of a%x (1<=x<=a-1). The first 100 numbers can be found in the pattern.
Is (a+1)/2-1. And then there's no more.
2 03 14 15 26 27 38 39 410 411 512 513 614 615 716 717 818 819 920 921 1022 1023 1124 1125 1226 1227 1328 1329 1430 1431 1 532 1533 1634 1635 1736 1737 1838 1839 1940 1941 2042 2043 2144 2145 2246 2247 2348 2349 2450 2451 2552 2553 2654 2655 275 6 2757 2858 2859 2960 2961 3062 3063 3164 3165 3266 3267 3368 3369 3470 3471 3572 3573 3674 3675 3776 3777 3878 3879 3980 3981 4082 4083 4184 4185 4286 4287 4388 4389 4490 4491 4592 4593 4694 4695 4796 4797 4898 4899 49100 49 Press any key to continue ...
#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 (find regular)