标签:
题很简单,主要是懂题意。
思想是枚举。
1 #include<cstdio> 2 #include<cstring> 3 4 #define Max 100001 5 6 int ans[Max]; 7 8 int main() 9 { 10 // freopen("in.txt","r",stdin); 11 memset(ans,0,sizeof(ans)); 12 for(int i = 1;i < 100001; i++){ 13 int x = i,y = i; 14 while(x > 0) { y += x%10; x /= 10; } 15 if(ans[y] == 0 || ans[y] > i) ans[y] = i; 16 } 17 int t; 18 scanf("%d",&t); 19 while(t--){ 20 int a; 21 scanf("%d",&a); 22 printf("%d\n",ans[a]); 23 } 24 return 0; 25 }
标签:
原文地址:http://www.cnblogs.com/Since-natural-ran/p/5974147.html