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

写一个push()函数就WA 直接就AC 求解释

Posted by coldsheep at 2012-02-16 21:41:40 on Problem 1426
#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:
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