Problem 2147 A-B Game (math AH)

Source: Internet
Author: User

Title Link: http://acm.fzu.edu.cn/problem.php?pid=2147


Problem 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 Input25 310086 outputcase 1:1case 2:7

Test instructions

Give the number a of two long integers, b. There is an action that changes a to: a=a-(a%x), where 1<=x<=a-1;

Ask at least how many times the operation can make a<=b.

The code is as follows:

#include <cstdio> #define LL __int64int Main () {    int cas=1;    LL t,a,b;    scanf ("%i64d", &t);    while (t--)    {        scanf ("%i64d%i64d", &a,&b);        LL i=0;        while (a>b)        {            a/=2;            i++;        }        printf ("Case%d:", cas++);        printf ("%i64d\n", I);    }    return 0;}


Problem 2147 A-B Game (math AH)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.