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

Re:为啥while(1)就AC,改成while(!s.empty())就WA呢??

Posted by NEU_14Michael at 2016-01-17 12:30:19 on Problem 1426
In Reply To:为啥while(1)就AC,改成while(!s.empty())就WA呢?? Posted by:201340702054 at 2014-11-14 18:59:54
> 为啥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;
> }

same..
why??

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