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

不知道错哪了,哪位大哥帮忙看看

Posted by x1e398u at 2005-12-02 18:30:52 on Problem 1252
j个coin能组成的cents由j-1个coin组成的cents加上一个coin构成,思路有错么?
#include <cstdio>
#include <queue>

using namespace std;

int main()
{
	int T;
	scanf("%d",&T);
	for(;T>0;T--)
	{
		int p[6],a[101]={0},size=6;
		queue<int> que;
		for(int i=0;i<6;i++)
		{
			scanf("%d",p+i);
			a[p[i]]=1;
			que.push(p[i]);
		}
		que.push(-1);
		int j=2,involve=0,tmp,tt;
		while(1)
		{
			tmp=que.front();
			que.pop();
			if(tmp==-1)
			{
				if(size==100) break;
				que.push(-1);
				j++;
				tmp=que.front();
				que.pop();
			}
			for(i=0;i<6;i++)
			{
				tt=tmp-p[i];
				if(tt>0 && !a[tt])
				{
					a[tt]=j;
					que.push(tt);
					size++;
				}
				tt=tmp+p[i];
				if(tt<=100 && !a[tt])
				{
					a[tt]=j;
					que.push(tt);
					size++;
				}
			}
		}
		for(i=1;i<101;i++)
			involve+=a[i];
		printf("%d.",involve/100);
		tmp=involve%100;
		if(tmp<10) printf("0");
		printf("%d %d\n",tmp,j);
	}
	return 0;
}

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