| ||||||||||
| 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 | |||||||||
为啥while(1)就AC,改成while(!s.empty())就WA呢??为啥while(1)就AC,改成while(!s.empty())就WA呢??
#include <stdio.h>
#include <iostream>
#include <queue>
using namespace std;
int n;
long long bfs()
{
queue<long long> s;
long long p;
s.push(1);
while(1)//改成while(!s.empty())就WA!!
{
p=s.front();
s.pop();
if(p%n==0)
return p;
s.push(p*10);
s.push(p*10+1);
}
}
int main()
{
while(scanf("%d",&n)&&n!=0)
{
long long m=bfs();
printf("%lld\n",m);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator