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 nestle at 2005-06-06 22:00:56 on Problem 2035
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main(){
int k,kase,NumOfPeo,sum,i,j,now;   
//int card[10][52],CountNum[10],NumOfCard[10],f[52][14],last[10],mi;
int card[11][55],CountNum[11],NumOfCard[11],f[55][15],last[11],mi;
bool can;
   for(k=1,scanf("%d",&kase);k<=kase;k++){
      scanf("%d",&NumOfPeo);
      sum=52;
      for(i=0;i<52;i++)  scanf("%d",&card[0][i]);
      for(i=0;i<NumOfPeo;i++){
         CountNum[i]=1;
         NumOfCard[i]=0;
      }
      NumOfCard[0]=52;    
      can=true;  now=0;
      while(sum&&can){
         i=CountNum[now];  j=0;
         /*cout<<now<<' '<<CountNum[now]<<' '<<NumOfCard[now]<<endl;
         for(int x=0;x<NumOfCard[now];x++){
            cout<<card[now][x]<<' ';
         }    cout<<endl;
         getch();*/
         if(!NumOfCard[now]){
            now=(now+1)%NumOfPeo;
            continue;
         }    
         memset(f,0,sizeof(f));
         while(1){
            if(f[j][i]){
               can=false;
               break;
            }
            else  f[j][i]=1;    
            if(i==card[now][j]){
               if(i<13)  CountNum[now]=i+1;
               else  CountNum[now]=1;
               last[now]=i;
               //cout<<"NumOfCard="<<NumOfCard[now]<<endl;
               --NumOfCard[now];
               for(mi=j;mi<NumOfCard[now];mi++)  card[now][mi]=card[now][mi+1];
               //cout<<"NumOfCard="<<NumOfCard[now]<<endl;
               if(now<NumOfPeo-1){
                  now++;
                  card[now][NumOfCard[now]++]=i;
                  //cout<<"ok"<<endl;
               }    
               else{
                  now=0;
                  sum--;
               }    
               break;
            }    
            i=i+1;
            if(i>13)  i=1;
            j=(j+1)%NumOfCard[now];
         }    
      }    
      printf("Case %d:",k);
      if(can)
         for(i=0;i<NumOfPeo;i++){
            printf(" %d",last[i]);
         }    
      else  printf(" unwinnable");
      printf("\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