lightoj1163数学思维

In one very cold morning, Mark decides to rob a bank. But while trying hacking into the security system, he found that it is locked by some random value. He also found a pattern on the random number, that is if he chops off the last digit of a number A, he gets a new number B. Then he calculates (A-B). He checked the first few numbers of the security system which exactly equals (A-B). Being very excited to have found the pattern, he learns that there are like 500 levels on the security system. He calculated all those numbers by hand but took a lot of time. As a sign of his accomplishment he left a note on the vault stating the pattern. You were the first officer on the crime scene and you've obtained the note. So if you can figure out A from (A-B), you can rob the bank very quick!

By the way, Mark succeeded in robbing the bank but had a heart attack on the getaway car and crashed.

Input

Input starts with an integer T (≤ 500), denoting the number of test cases.

Each line contains a single positive integer between 10 and 1018(inclusive), giving the value of A-B.

Output

For each case, print the case number and the possible values of A in ascending order. Separate consecutive numbers with a single space.

Sample Input

4

31

18

12

17

Sample Output

Case 1: 34

Case 2: 19 20

Case 3: 13

Case 4: 18

b=a/10;

设a-b为c,最后一位为x

a-a/10=c;

10*a-10*(a/10)=10*c;

10*a-10*(a/10)-x=10*c-x;

9*a=10*c-x;

枚举最后一位即可 

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
int t;
unsigned long long a,b;
unsigned long long ans[205];
int cnt;
int main()
{
    scanf("%d",&t);
    int w=0;
    while(t--)
    {w++;
        scanf("%llu",&b);

        memset(ans,0,sizeof(ans));
        cnt=0;
        for(int i=9;i>=0;i--)
        {

          if((10*b-i)%9==0)
           ans[cnt++]=(10*b-i)/9;

        }
        printf("Case %d: ",w);
        for(int i=0;i<cnt-1;i++)
            printf("%llu ",ans[i]);
        printf("%llu\n",ans[cnt-1]);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/sdauguanweihong/article/details/89816510