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 |
写一个push()函数就WA 直接就AC 求解释#include<iostream> using namespace std; long long int que[10000000]; int bot,top; int x; void bfs(){ bot=top=0; long long int n; que[top++]=1; while(bot<top){ n=que[bot++]; if(n%x==0){ printf("%lld\n",n); return ; } n*=10; que[top++]=n; n+=1; que[top++]=n; } } int main(){ while(scanf("%d",&x)&&x){ bfs(); } system("pause"); return 0; } AC #include<iostream> using namespace std; long long int que[10000000]; int bot,top; int x; void push(int y){ que[top++]=y; } void bfs(){ bot=top=0; long long int n; push(1); //que[top++]=1; while(bot<top){ n=que[bot++]; if(n%x==0){ printf("%lld\n",n); return ; } n*=10; push(n); //que[top++]=n; n+=1; push(n); //que[top++]=n; } } int main(){ while(scanf("%d",&x)&&x){ bfs(); } system("pause"); return 0; } 就WA。。。。。 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator