UVa 1583

A+A的每一位的数字的和=B

问你每一个B对应 的最小的A 是多少

不然输出0;

 1 #include <cstdio>
 2 #include <iostream>
 3 #include <cstring>
 4 using namespace std;
 5 const int N=100005;
 6 int ans[2*N],tmp,cnt,n,t;
 7 void fuc(){
 8     memset(ans,0,sizeof(ans));
 9     for(int i=1;i<=N;i++){
10         tmp=i; cnt=0;
11         while(tmp>0){
12             cnt+=tmp%10;
13             tmp/=10;
14         }
15         cnt+=i;
16         if(ans[cnt]==0) ans[cnt]=i;
17     }
18 }
19 int main()
20 {
21     fuc();
22     scanf("%d",&t);
23     while(t--){
24         scanf("%d",&n);
25         printf("%d
",ans[n]);
26     }
27 } 
我自倾杯,君且随意
原文地址:https://www.cnblogs.com/nicetomeetu/p/5275260.html