FZU 2147 A-B Game

原创 2018年04月15日 22:12:40

A-B Game

Problem 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

题解代码

#include <iostream>
#include <cstring>
using namespace std;
int main(){
    long long n;
    while (cin >> n){
        for(long long i = 1;i <=n; i++){
            long long a,b;
            cin >> a >> b;
            long long ans = 0;
            while (a>b){
                a = a-a%(a/2+1);
                ans++;
            }
            cout<<"Case "<<i<<":"<<" "<<ans<<endl;
        }
    }

    return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/AcmAres/article/details/79954204

FZU-2147 A-B Game

#include #include int t, cas; long long a, b;int main() { cas = 0; scanf("%d", & t); wh...
  • somniloquy_
  • somniloquy_
  • 2015-08-23 19:06:54
  • 219

FZU2147 A-B Game(贪心)

题意        输入A、B(B - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ...
  • codeNk17
  • codeNk17
  • 2014-11-18 16:33:04
  • 343

A-B Game FZU - 2147

A-B Game FZU - 2147 Fat brother and ...
  • codeswarrior
  • codeswarrior
  • 2018-04-14 16:36:17
  • 8

FZU 2147 A-B Game

关键是找出规律,其次再说贪心吧= = #include #include using namespace std; int main() { int t, cas = 0; ...
  • MrSiz
  • MrSiz
  • 2016-03-30 22:59:56
  • 272

FZU Problem 2147 A-B Game (数学啊)

FZU Problem 2147 A-B Game (数学啊)
  • u012860063
  • u012860063
  • 2014-12-03 18:39:50
  • 1002

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

A-B Game Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Submit ...
  • qq_18738333
  • qq_18738333
  • 2015-04-12 23:45:41
  • 670

【瞎搞】 FZU 2147 A-B Game

点击打开链接 x∈[1,A-1]; 要求 A%x 最大  所以x=A/2+1; #include #include #include #include #include #...
  • u012749539
  • u012749539
  • 2014-12-03 20:26:14
  • 535

FZU 2147 A-B Game(数学推导题)

H - A-B Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit...
  • qq_18661257
  • qq_18661257
  • 2016-08-12 19:20:15
  • 402

FZU OJ 2147 A-B Game (数学水题)

Problem 2147 A-B Game Accept: 827    Submit: 1940 Time Limit: 1000 mSec    Memory Limit : 32768 ...
  • u014253173
  • u014253173
  • 2015-05-23 23:02:20
  • 1387

FZU-Problem 2147 A-B Game

Problem 2147 A-B Game Accept: 503    Submit: 1214 Time Limit: 1000 mSec    Memory Limit : 32768 ...
  • u012773338
  • u012773338
  • 2014-08-02 10:28:05
  • 598
收藏助手
不良信息举报
您举报文章:FZU 2147 A-B Game
举报原因:
原因补充:

(最多只允许输入30个字)