欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

UVa 1583 - Digit Generator

发布时间:2025/7/25 46 豆豆
生活随笔 收集整理的这篇文章主要介绍了 UVa 1583 - Digit Generator 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

  感觉写的代码还是和以前一样的赘长。

  第一次交的超时了,然后把每个数对应的解存了起来,直接读取,AC了。


 

#include<stdio.h> int str[100000]={0}; int main() {int i,j,n,T;int sum=0,d;for(j=1; j<=100000; j++){d=sum=j;while(d!=0){sum+=d%10;d/=10;}if((str[sum]!=0)&&(str[sum]<j))continue;str[sum]=j;}scanf("%d",&T);for(i=0;i<T;i++){scanf("%d",&n);printf("%d\n",str[n]);}return 0; }


 

转载于:https://www.cnblogs.com/xuziye0327/p/4101665.html

总结

以上是生活随笔为你收集整理的UVa 1583 - Digit Generator的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。