标签:http puts include mod article strong scan .net size
#include<cstdio> #include<cstring> const int N=1e6+88; bool vis[N]; char ans[N]; int main() { int n; while(scanf("%d",&n),n) { if(n==1) { puts("0123456789"); continue; } memset(vis,0,sizeof(vis)); int mod=1,end=1,pos=n; for(int i=1; i<=n; ++i) mod*=10,end*=10; mod/=10; end+=n-1; for(int i=0; i<n; ++i) ans[i]=‘0‘; vis[0]=1; int now=0,i=0; while(pos<end) { now%=mod; for(; i<10; ++i) if(!vis[now*10+i]) { vis[now*10+i]=1; ans[pos++]=i+‘0‘; now=now*10+i; i=0; break; } if(i==10&&pos<end) { --pos; now=(ans[pos-n+1]-‘0‘)*mod+now; vis[now]=0; i=now%10+1; now/=10; } } ans[end]=‘\0‘; printf("%s\n",ans); } }
标签:http puts include mod article strong scan .net size
原文地址:http://www.cnblogs.com/mfys/p/7657980.html