#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define maxn 100005
int ans[maxn];
int main(){
int T,n;
memset(ans,0,sizeof(ans));
for(int i=1;i<maxn;i++){
int x=i,y=i;
while(x>0){
y+=x%10;
x/=10;
}
if(ans[y]==0||i<ans[y])
ans[y]=i;
}
scanf("%d",&T);
while(T--){
scanf("%d",&n);
printf("%d\n",ans[n]);
}
return 0;
}
算法入门 例题3-5 生成元
猜你喜欢
转载自blog.csdn.net/qq_41138935/article/details/81075551
今日推荐
周排行