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 like680623 at 2010-12-02 21:25:16 on Problem 2709
一看分类竟然是贪心,不知所措啊。。(今天刚学贪心,啥也不会),后面试了下暴力,RP爆发啊。。。一次就A了。。。。。0ms。。。
把史上最简单的代码给初学者分享:
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int tot;
	int i;
	int num[13];
	while (scanf("%d", &tot) == 1)
	{
		if (tot == 0)
			return 0;
		for (i = 0; i <= tot; i++)
			scanf("%d", &num[i]);
			while (num[tot] > 0)
			{
				sort(num, num + tot);
				num[0]++;
				num[1]++;
				num[2]++;
				num[tot]--;
			}
			if (num[tot] == 0)
			{
				sort(num, num + tot);
				if (num[tot - 1] % 50 == 0)
					printf("%d\n", num[tot - 1] / 50);
				else printf("%d\n", num[tot - 1] / 50 + 1);
			}
	}
}

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