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

表示这个SPJ有问题

Posted by duanxian0621 at 2011-08-02 20:56:18 on Problem 1426
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;

__int64 a[250];
int oper[2]={0,1};
__int64 bfs(int n)
{
	int j;
	queue<__int64> q;
	q.push(1);
	while(!q.empty())
	{
		__int64 head,next;
		head=q.front();
		q.pop();
		for(j=0;j<2;j++)
		{	
			next=head*10+oper[j];
			if(next%n==0) 
				return next;	
			q.push(next);
		}
	}
}

int main()
{
	int i,j;
	//freopen("1.txt","w",stdout);
	memset(a,0,sizeof(a));
	for(i=200;i>=1;i--)
		a[i]=bfs(i);
	//for(i=99;i>=1;i--)
	//	a[i]=a[2*i];
	while(scanf("%d",&i),i)
		printf("%I64d\n",a[i]);
	return 0;
}
直接预处理全部打出来,竟然报wrong。  而不先预处理就AC了

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