| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
求教:测试了几千组数据正确,但还是WA#include <iostream>
using namespace std;
int v[6];
int main()
{
while(cin>>v[0]>>v[1]>>v[2]>>v[3]>>v[4]>>v[5])
{
if(v[0]==0&&v[1]==0&&v[2]==0&&v[3]==0&&v[4]==0&&v[5]==0)
break;
bool flag=false;
int n=v[5];
v[5]=0;
while(!flag)
{
int V=36;
int H=6;
for(int j=4;j>=0;j--)
{
if(v[j]==0||j+1>H||(j+1)*(j+1)>V);
else
{
if(j+1>=4)
H=H-j-1;
else if(j+1==3)
{
if(v[j]>=4)
{
v[j]=v[j]-4;V=V-36;
continue;
}
else if(v[j]==3)
{
V=V-27;
if(v[1]>=1)
{
v[1]--;V=V-4;
}
}
else if(v[j]==2)
{
V=V-18;
if(v[1]>=3)
{
v[1]=v[1]-3;V=V-12;
}
else
{
V=V-4*v[1];v[1]=0;
}
}
else if(v[j]==1)
{
V=V-9;
if(v[1]>=5)
{
v[1]=v[1]-5;V=V-20;
}
else
{
V=V-4*v[1];v[1]=0;
}
}
v[j]=0;
j=1;
continue;
}
V=V-(j+1)*(j+1);
v[j]--;
if(v[j]!=0)
j++;
}
if(j==0||V==0)
{
j=0;
n++;
for(int t=0;t<6;t++)
{
if(t==5)
{
flag=true;break;
}
if(v[t]!=0)
break;
}
}
}
if(flag)
break;
}
cout<<n<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator