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

Re:贴代码

Posted by yzhw at 2009-05-30 12:27:02 on Problem 1082
In Reply To:Re:如果之后两个状态都必胜,那么此状态必败;如果之后两个状态有一个必败,那么此状态必胜。2001.11.4是必败点,之后的都是必胜点 Posted by:yzhw at 2009-05-30 12:26:18
Source Code

Problem: 1082  User: yzhw 
Memory: 552K  Time: 0MS 
Language: GCC  Result: Accepted 

Source Code 
# include <stdio.h>
# include <string.h>
# include <stdbool.h>
char refer[102][13][32];
int cul(int y,int m)
{
   if(m==1||m==3||m==5||m==7||m==8||m==10||m==12) return 31;
   else if(m==2)
   {
        if((y%100!=0&&y%4==0)||y%400==0) return 29;
        else return 28;
   }
   else return 30;
}
bool chk1(int *y,int *m,int *d)
{
    if((*d)+1<=cul(*y,*m))
    {
      (*d)++;
      return 1;
    }
    else
    {
        if((*m)!=12)
        {
         (*m)++;
         (*d)=1;
         return 1;
         }
         else
         {
          (*m)=1;
          (*y)++;
          (*d)=1;
          return 1;
         }
    }
}
bool chk2(int *y,int *m,int *d)
{
     if((*m)!=12)
     {
      (*m)++;
      if((*d)>cul(*y,*m)) return 0;
      else return 1;
     }
     else
     {
         (*m)=1;
         (*y)++;
         return 1;
     }
}
char jud(int y,int m,int d)
{
   if(y==2001&&m==11&&d==4) return 2;
   else if(y>2001||(y==2001&&m>11)||(y==2001&&m==11&&d>4)) return 1;
   else if(refer[y-1900][m][d]) return refer[y-1900][m][d];
   else
   {
      int ty1=y,tm1=m,td1=d,ty2=y,tm2=m,td2=d;
      if(chk2(&ty1,&tm1,&td1))
      {
        chk1(&ty2,&tm2,&td2);
        if(jud(ty1,tm1,td1)==2||jud(ty2,tm2,td2)==2)
        {
            refer[y-1900][m][d]=1;
            return 1;
        }
        else if(jud(ty1,tm1,td1)==1&&jud(ty2,tm2,td2)==1)
        {
             refer[y-1900][m][d]=2;
             return 2;
        }
      }
      else
      {
          chk1(&ty2,&tm2,&td2);
          if(jud(ty2,tm2,td2)==2)
          {
             refer[y-1900][m][d]=1;
             return 1;
          }
          else
          {
              refer[y-1900][m][d]=2;
              return 2;
          }
      }
   }
}
int main()
{
    int testcase;
    memset(refer,0,sizeof(refer));
    scanf("%d",&testcase);
    while(testcase--)
    {
     int y,m,d;
     scanf("%d %d %d",&y,&m,&d);
     if(jud(y,m,d)==1) 
		 printf("YES\n");
     else printf("NO\n");
    }
    system("pause");
    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