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了n次还独自徘徊,蓦然回首间,点了一下discuss,瞬间整个世界都温暖了。。。

Posted by 2004140022 at 2015-09-22 10:07:45 on Problem 1017
rt
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
#define N 7
int s[N];
int main()
{


    int i,sum,n,tmps,tmpk;

    while(1)
    {
        sum=0;
        n=0;
        int a[4]={0,5,3,1};
        for(i=0;i<6;i++)
            scanf("%d",&s[i]);
        if(!s[0]&&!s[1]&&!s[2]&&!s[3]&&!s[4]&&!s[5])
            break;
        n+=s[5]+s[4]+s[3]+(s[2]+3)/4;
        sum=5*s[3]+a[s[2]%4];
        if(s[1]>sum)
            n+=(s[1]-sum+8)/9;
        sum=36*n-36*s[5]-25*s[4]-16*s[3]-9*s[2]-4*s[1];
        if(s[0]>sum)
            n+=(s[0]-sum+35)/36;

#if 0
        n+=s[5]+s[4]+s[3];
        if(s[4])
        {
            if(s[0]>s[4]*91)
                s[0]-=s[4]*91;
            else
                s[0]=0;
        }
        if(s[3])
        {
            if(s[1]>s[3]*19)
               {
                    s[1]-=s[3]*19;
               }
            else
               {
                   tmps=s[1]%19;
                   tmpk=s[1]/19;
                   sum=(s[3]-tmpk-1)*152+(216-tmps*64);
                   if(s[0]>sum)
                        s[0]-=sum;
                   else s[0]=0;
                   s[1]=0;
               }
        }
        if(s[2])
        {
            n+=s[2]/8;
            tmps=s[2]%8;
            if(tmps){
            n++;
            switch(tmps)
            {
                case 0:break;
                case 1:tmpk=19;break;
                case 2:tmpk=15;break;
                case 3:tmpk=10;break;
                case 4:tmpk=9;break;
                case 5:tmpk=4;break;
                case 6:tmpk=3;break;
                case 7:tmpk=1;break;

            }
            if(s[1]>tmpk)
            {
                s[1]-=tmpk;
                sum=216-tmps*27-tmpk*8;

            }
            else
            {
                sum=216-s[1]*8-tmps*27;
                s[1]=0;
            }
             if(s[0]>sum)
                    s[0]-=sum;
                else s[0]=0;
            }

        }
        if(s[1])
        {
            n+=s[1]/27;
            tmps=s[1]%27;
            if(tmps)
            {
                n++;
                sum=216-tmps*8;
                if(s[0]>sum)
                    s[0]-=sum;
                else s[0]=0;
            }
        }
        if(s[0])
        {
            n+=s[0]/216;
            if(s[0]%216!=0)
                n++;
        }
#endif
        printf("%d\n",n);

    }


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