Bank Robbery LightOJ - 1163(公式化简)

题目链接

题意:给你一个B,已知A-A/10=B。让你求A。

思路:两边同时乘以10,得到10*A-A+x=10*B,所以A=(10*B-x)/9。而x的范围为0~9,所以枚举即可。

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<map>
#include<vector>
#include<algorithm>
#define N 2000006
#define ll long long
#define ull unsigned long long 
using namespace std;
int main()
{
    int t;
    int u=0;
    scanf("%d",&t);
    while(t--)
    {
        ull n;
        scanf("%llu",&n);
        printf("Case %d:",++u);
        for(int i=9;i>=0;i--)
        {
            ull v=10*n-i;
            if(v%9==0)
            {
                printf(" %llu",v/9);
            }
        }
        printf("\n");
     }  
}

 

posted @ 2020-09-18 14:59  Ldler  Views(104)  Comments(0Edit  收藏  举报