include
include
define maxn 100005
int ans[maxn];
int main()
{
int T,n;
int m;
memset(ans,0,sizeof(ans));/将数组全部初始化为0/
for(m = 1;m < maxn;m++)
{
int x = m,y = m;
while(x > 0){y += x % 10;x /= 10;} /计算m是哪个数的生成元/
if(ans[y] == 0 || m < ans[y]) ans[y] = m; /判断数组下标为生成元处的变量,如果为0则存入m,如果存在数字但比m大,存入m/
}
scanf(“%d”,&T); /选择输入多少次/
while(T–)
{
scanf(“%d”,&n);
printf(“%d\n”,ans[n]);
}
return 0;
}