Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

大神帮忙看看代码

Posted by a137567878 at 2014-07-21 10:44:09 on Problem 1426
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator