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 csulk at 2010-07-15 11:16:41 on Problem 1017
#include <stdio.h>
int main(void)
{
	int a[6] = {0};
	int i, j, n = 6;
	while(1)
	{
		int flag = 0, res = 0;
		int b[6] = {0};
		for(i = 0; i < n; ++i)
		{
			scanf("%d", &a[i]);
			if(a[i])flag = 1;
		}
		if(!flag)break;
		res = a[5] + a[4] + a[3];
		b[0] = 11 * a[4];		//可以装1*1的数目
		b[1] = 5 * a[3];
		res += a[2] / 4;
		if(a[2] % 4 == 1)
		{
			++res;
			b[1] += 5;
			b[0] += 7;
		}
		else if(a[2] % 4 == 2)
		{
			++res;
			b[1] += 3;
			b[0] += 6;
		}
		else if(a[2] % 4 == 3)
		{
			++res;
			b[1] += 1;
			b[0] += 5;
		}
		a[1] -= b[1];
		if(a[1] <= 0)
		{
			a[1] += b[1];
			b[0] += (b[1] - a[1]) * 4;
		}
		else
		{
			res += a[1] / 9;
			if(a[1] % 9 != 0)
			{
				++res;
				b[0] += (9 - a[1] % 9) * 4;
			}
		}
		a[0] -= b[0];
		if(a[0] > 0)
		{
			res += a[0] / 36;
			if(a[0] % 36 != 0)++res;
		}
		printf("%d\n", res);
	}
	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