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 Pro_zhangdashi at 2009-08-14 13:59:16 on Problem 2014
最后的是小写的x


附带自己的垃圾代码,对你理解题意应该有所帮助,不要想的太复杂
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#include <stdio.h>
//Each rectangle is between 1 and 80 units wide (inclusive) and between 1 and 100 units high (inclusive). 

int main(void)
{
	int m = 0;// 1 <= m <= 80   maximum width of the resulting window
	int i = 0, count = 0;
	int dimensions[16][2] ={0};
	int max_x = 0, max_y_0 = 0, max_y_1 = 0;
	int cur_x = 0;
	while(1)
	{
		max_x =0, max_y_0 = 0, max_y_1 = 0, cur_x = 0, count = 0;
		i = 0;
		scanf("%d", &m);
		if(m == 0)
			break;
		while(1)
		{
			scanf("%d%d", &dimensions[i][0], &dimensions[i][1]);
			if((dimensions[i][0] == -1) && (dimensions[i][1] == -1))
				break;
			else
			{
				i++;
				count++;
			}
		}
		for(i = 0; i < count; i++)
		{
			if((cur_x + dimensions[i][0]) > m)
			{
				cur_x = 0;
				cur_x += dimensions[i][0];
				if(cur_x >max_x)
					max_x = cur_x;
				max_y_0 += max_y_1;
				if(i == count-1)
					max_y_0 += dimensions[i][1];
				max_y_1 = dimensions[i][1];
			}
			else
			{
				cur_x += dimensions[i][0];
				if(cur_x > max_x)
					max_x = cur_x;
				if(dimensions[i][1] > max_y_1)
					max_y_1 = dimensions[i][1];
				if(i == count-1)
					max_y_0 += max_y_1;
			}
		}
		printf("%d x %d\n", max_x, max_y_0);
	}
	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