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> using namespace std; struct Node{ int data; int p; int pre; Node():pre(0){ } }; struct que{ Node a[10009]; int s; int e; }; int n; que q; void print(int w){ if(w==0){ cout<<q.a[0].data; return; } else{ print(q.a[w].p); cout<<q.a[w].data; } } void bfs(){ q.s=0; q.e=0; q.a[q.s].data=1; q.a[q.s].p=-1; q.e++; while(q.s!=q.e){ Node f=q.a[q.s]; int k=f.data+f.pre*10; f.pre=k%n; if(!f.pre){ print(f.p); cout<<f.data<<endl; return ; } else{ q.a[q.e].data=1; q.a[q.e].p=q.s; q.a[q.e].pre=f.pre; q.e++; q.a[q.e].data=0; q.a[q.e].p=q.s; q.a[q.e].pre=f.pre; q.e++; } q.s++; } } int main() { while(1){ cin>>n; if(n==0) break; else bfs(); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator