Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
大神帮忙看看代码#include<iostream> #include<stdio.h> #include<string.h> using namespace std; int vis[210],ans[210],n,tot; bool judge; void dfs(int x,int step) { if(x==0) { tot=0; judge=true; return; } if(!vis[x]) { vis[x]=1; dfs((x*10)%n,step+1); if(judge) { ans[++tot]=0; return; } vis[x]=0; } if(!vis[x]) { vis[x]=1; dfs((x*10+1)%n,step+1); if(judge) { ans[++tot]=1; return; } //vis[x]=0; } } int main() { while(scanf("%d",&n)) { if(n==0)break; memset(vis,0,sizeof(vis)); judge=false; dfs(1,1); if(!judge)break; ans[++tot]=1; for(int i=tot;i>=1;i--) printf("%d",ans[i]); printf("\n"); } return 0; } 打表可以从1输出到200.judge都为正。但为什么WA Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator