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

菜鸟自己写的超长代码.....纯模拟每一个状态16ms

Posted by 20101421 at 2012-03-31 21:42:17 on Problem 1017
#include<stdio.h>
#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c,d,e,f,x,answer;
    while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!=EOF)
    {
        if(a==0&&b==0&&c==0&&d==0&&e==0&&f==0)
        break;
        answer = f+e+d;
        if(a-11*e>=0) a=a-11*e;
        else a=-1;
        if(b-5*d>=0) b=b-5*d;
        else {x=b;b=-1;}
        if(b==-1&&a>0) a=a-(20*d-4*x);
        if(c%4==0)
        answer=answer+c/4;
        else answer=answer+c/4+1;
        //printf("%d %d %d",a,b,c);
        c=c%4;
        if(c==3)
        {
            if(b>0||a>0)
            {
                b=b-1;
                a=a-5;
                if(b<=0)
                {
                    if(a>0)
                    {
                        if(a%36==0)
                        answer=answer+a/36;
                        else answer=answer+a/36+1;
                    }
                }

                else
                {
                    if(b%9==0)
                    answer=answer+b/9;
                    else  answer=answer+b/9+1;
                    b=b%9;
                     if(a>0)
                     {
                        if(b==0)
                        {
                        if(a%36==0)
                        answer=answer+a/36;
                        else answer=answer+a/36+1;
                        }
                        else
                        {
                          a=a-(36-b*4);
                         if(a>0)
                         {
                        if(a%36==0)
                        answer=answer+a/36;
                        else answer=answer+a/36+1;

                         }
                    }
                }
            }

        }

    }

    else if(c==2)
    {
        if(b>0||a>0)
        {
             b=b-3;
             a=a-6;
           if(b<=0)
                {
                    if(a>0)
                    {
                        if(a%36==0)
                        answer=answer+a/36;
                        else answer=answer+a/36+1;
                    }
                }

                else
                {
                    if(b%9==0)
                    answer=answer+b/9;
                    else  answer=answer+b/9+1;
                    b=b%9;
                     if(a>0)
                     {
                        if(b==0)
                        {
                        if(a%36==0)
                        answer=answer+a/36;
                        else answer=answer+a/36+1;
                        }
                        else
                        {
                          a=a-(36-b*4);
                         if(a>0)
                         {
                        if(a%36==0)
                        answer=answer+a/36;
                        else answer=answer+a/36+1;

                         }
                    }
                }
            }

        }

    }
    else if(c==1)
    {
        if(b>0||a>0)
        {
             b=b-5;
             a=a-7;
           if(b<=0)
                {
                    if(a>0)
                    {
                        if(a%36==0)
                        answer=answer+a/36;
                        else answer=answer+a/36+1;
                    }
                }

                else
                {
                    if(b%9==0)
                    answer=answer+b/9;
                    else  answer=answer+b/9+1;
                    b=b%9;
                     if(a>0)
                     {
                        if(b==0)
                        {
                        if(a%36==0)
                        answer=answer+a/36;
                        else answer=answer+a/36+1;
                        }
                        else
                        {
                          a=a-(36-b*4);
                         if(a>0)
                         {
                        if(a%36==0)
                        answer=answer+a/36;
                        else answer=answer+a/36+1;

                         }
                    }
                }
            }

        }


    }

    else if(c==0)
    {
       if(b>0||a>0)
        {           if(b>0)
                    {if(b%9==0)
                    answer=answer+b/9;
                    else  answer=answer+b/9+1;
                        b=b%9;
                      if(a>0)
                     {
                        if(b==0)
                        {
                        if(a%36==0)
                        answer=answer+a/36;
                        else answer=answer+a/36+1;
                        }
                        else
                        {
                          a=a-(36-b*4);
                         if(a>0)
                         {
                        if(a%36==0)
                        answer=answer+a/36;
                        else answer=answer+a/36+1;

                         }
                    }
                }
                       }
                        else
                        {
                            if(a>0)
                         {
                        if(a%36==0)
                        answer=answer+a/36;
                        else answer=answer+a/36+1;
                          }
                    }
               }
            }


    printf("%d\n",answer);
    }
    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