zoj 1024
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
-------------------
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <iostream> 2 #include <fstream> 3 using namespace std; 4 5 int c = 0;// 6 int isleap; 7 const int cal[2][15]={ 8 {0,31,28,31,30,31,30,31,31,30,31,30,31}, 9 {0,31,29,31,30,31,30,31,31,30,31,30,31}//leap year 10 }; 11 bool calendar[2002][13][32] = {0};//0 is lost when start from this date 12 int year,month,day; 13 14 bool win_by_month() 15 { 16 if(year < 2001 || (month < 10 || (month == 10 && day <= 4)))//下一跳日期<=2001-11-4 17 { 18 if(month < 12){ 19 if(cal[isleap][month+1] >= day && calendar[year][month+1][day] == 0)//下一跳为必输可达日期 20 return 1; 21 } 22 else{ 23 if(calendar[year+1][1][day] == 0) 24 return 1; 25 } 26 } 27 return 0; 28 } 29 bool win_by_day() 30 { 31 if(year < 2001 || month < 11 || (month == 11 && day < 4)){ 32 if(day < cal[isleap][month]){ 33 if(calendar[year][month][day+1] == 0 ) 34 return 1; 35 } 36 else { 37 if(month < 12){ 38 if(calendar[year][month+1][1] == 0) 39 return 1; 40 } 41 else{ 42 if(calendar[year + 1][1][1] == 0) 43 return 1; 44 } 45 } 46 } 47 return 0; 48 } 49 void getleap() 50 { 51 if(year%400==0||(year%4==0&&year%100!=0)) isleap = 1; 52 else isleap = 0; 53 return ; 54 } 55 56 void init() 57 { 58 for(year = 2001; year >= 1900; --year){ 59 getleap(); 60 for(month = 12; month >= 1; --month){ 61 for(day = cal[isleap][month]; day >= 1; --day){ 62 if(calendar[year][month][day] == 0){ 63 if(win_by_month()){ 64 calendar[year][month][day] = 1;c++;// 65 continue; 66 } 67 if(win_by_day()){ 68 calendar[year][month][day] = 1;c++;// 69 } 70 } 71 } 72 } 73 }//cout<< " c= "<< c <<endl;// 74 return ; 75 } 76 77 int main() 78 { 79 /*ifstream cin("1.txt");//*/ 80 /*ofstream cout("2.txt");//*/ 81 int cas; 82 83 init(); 84 cin>>cas; 85 86 while(cas--) 87 { 88 cin>>year>>month>>day; 89 if(calendar[year][month][day] == 1) 90 cout<<"YES"<<endl; 91 else 92 cout<<"NO"<<endl; 93 } 94 return 0; 95 }
1 #include <iostream> 2 #include <fstream> 3 using namespace std; 4 5 int main() 6 { 7 //ifstream cin("1.txt"); 8 int t; 9 int year; 10 int month; 11 int day; 12 cin>>t; 13 14 for(int i=0; i<t; i++) 15 { 16 cin>>year>>month>>day; 17 18 if(month == 9 && day == 30) 19 { 20 cout<<"YES"<<endl; 21 continue; 22 } 23 24 if(month == 11 && day == 30) 25 { 26 cout<<"YES"<<endl; 27 continue; 28 } 29 30 if((month + day)%2 == 0) 31 cout<<"YES"<<endl; 32 else 33 cout<<"NO"<<endl; 34 } 35 36 return 0; 37 }