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 adamgic at 2005-04-07 22:43:25 on Problem 1017
#include <iostream>
using namespace std;
bool fill(long int *good)
{
    int limit[6];
    limit[0]=36;
    limit[1]=9;
    limit[2]=4;
    limit[3]=1;
    limit[4]=1;
    if(good[4]){
        --good[4];
        limit[0]=11;
        limit[1]=0;
        limit[2]=0;
        limit[3]=0;
    } 
    if(good[3]&&limit[3])
    {
        --good[3];
        limit[0]=20;
        limit[1]=5;
        limit[2]=0;
    }       
    if(good[2]&&limit[2])
    {
        if(good[2]<limit[2]){
            if(good[2]==1)limit[1]=5;
            if(good[2]==2)limit[1]=3;
            if(good[2]==3)limit[1]=1;
            limit[0]=36-good[2]*9;
            good[2]=0;
        }
        else {
            good[2]-=limit[2];
            limit[1]=0;
            limit[0]=0;
        }
    }    
    if(good[1]&&limit[1])
    {
        if(limit[1]==5&&limit[2]==0){
            if(good[1]<limit[1]){
                limit[0]=20-4*good[1];
                good[1]=0;
            }
            else{
                limit[0]=0;
                good[1]-=limit[1];
            }
        }
        else {
            if(good[1]<limit[1]){limit[0]=limit[0]-good[1]*4;good[1]=0;}
            else {
                if(limit[1]==5)limit[0]=7;
                if(limit[1]==3)limit[0]=6;
                if(limit[1]==1)limit[0]=5;
                good[1]-=limit[1];
            }
        }
    }        
    if(good[0]&&limit[0])
    {
        if(good[0]<limit[0]){good[0]=0;}
        else {good[0]-=limit[0];}
    }   
    if(good[0]||good[1]||good[2]||good[3]||good[4]||good[5])return false;
    else return true;
}    
int main(void)
{
    do{
        long int  good[6];
        long int flag=0;
        for(int i=0;i<6;i++){
            cin>>good[i];
            if(good[i]!=0)flag=1;
        }    
        if(flag==0)break;
        long int temp=0;
        temp+=good[5];
        good[5]=0;
        if(!(good[0]||good[1]||good[2]||good[3]||good[4]||good[5])){
            cout<<temp<<endl;
            continue;
        }
        long index=0;
        do{
            index++;
            if(fill(good))break;
        }while(1);
        cout<<index+temp<<endl;
    }while(1);
} 

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