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

测量好多数据都可以,怎么还是WA啊

Posted by 20120702 at 2012-07-06 11:46:05 on Problem 1017
//首先是用6*6的装6*6的,然后用6*6的装5*5的再将剩余的空间装1*1的,再用6*6装4*4的,
//剩余的空间先装2*2的如果还有空间剩余再装1*1.在6*6装3*3是重点,显示看装三个个数,
//如果装的是4个那么没有空间剩余,如果装的三个3*3的那么可以装1个2*2的和5个1*1的,
//如果装的是两个3*3的那么可以装2*2的3个和1*1的6个,还有3*3的1个的时候可以装2*2的五个其他的全装1*1的
#include<iostream>
#include<cmath>
#include<vector>
int solve(int s[7])
{
	int total = 0;
	total += s[6];//6*6只能独自占用一个盒子

	total += s[5]; //装5*5的
	s[1] -= s[5]*11;
	if(s[1] < 0) 
		s[1] = 0;

	total += s[4];//装4*4的
	s[2] -= s[4] * 5;//剩余空间装2*2的
	if(s[2] < 0)//如果还有多的,装1*1的
	{
		int t = 4*(-s[2]);
		s[1] -= t;
		if(s[1] < 0)
			s[1] = 0;
	}


	if(s[3] > 0)
	{
		total += s[3]/4 + 1;//装3*3
		switch(s[3]%4)//有剩余空间
		{
		case 0: total -= 1;
				break;
		case 1:	s[2] -= 5;
				s[1] -= 7;
				if(s[2] <= 0)
				{
					s[1] -= 4*(-s[2]);
					if(s[1] < 0)
						s[1] = 0;
				}
				break;
		case 2:	s[2] -= 3;
				s[1] -= 6;
				if(s[2] <= 0)
				{
					s[1] -= 4*(-s[2]);
					if(s[1] < 0)
						s[1] = 0;
				}
				break;
		case 3:	s[2] -= 1;
				s[1] -= 5;
				if(s[2] <= 0)
				{
					s[1] -= 4*(-s[2]);
					if(s[1] < 0)
						s[1] = 0;
				}
		default: break;	
		}
		
	}
	


	if(s[2] > 0)
	{
		total += s[2]/9 + 1;//装2*2的
		if(s[2]%9 == 0)
			total -= 1;
		else
		{
			s[1] -= (9 - s[2]%9)*4;
			if(s[1] < 0)
				s[1] = 0;
		}
	}


	if(s[1] > 0)//装1*1的
		total += (int)ceil(1.0*s[1]/36);
	return total;
	
}
int main()
{
	std::vector<int> resultvec;
	int s[7];//s[i]分别表示(i*i)的个数
	while(1)
	{
		int i, sum = 0;
		for(i = 1; i <= 6; i++)
		{
			std::cin >> s[i];
			sum += s[i];
		}
		if(sum == 0)//输入全为零,终止
			break;
		resultvec.push_back(solve(s));

	}
	for(std::vector<int>::iterator it = resultvec.begin(); it != resultvec.end(); ++it)
	{
		std::cout << *it << std::endl;
	}
	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