标签:一个 超过 -- hdu mit source date 问题: nbsp
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 719 Accepted Submission(s): 228
1 #include<bits/stdc++.h> 2 using namespace std; 3 struct MyDate 4 { 5 int year; 6 int month; 7 int day; 8 }; 9 bool isr(int r){return r%4==0 && r%100!=0 || r%400==0;} 10 int GetAbsDays(MyDate x) 11 { 12 int i; 13 int month_day[] = {31,28,31,30,31,30,31,31,30,31,30,31}; 14 int year = x.year-1; 15 int days = year * 365 + year/4 - year/100 + year/400; 16 if(isr(x.year)) month_day[1]++; 17 for(i=0; i<x.month-1; i++) 18 days += month_day[i]; 19 days += x.day-1; 20 return days; 21 } 22 int GetDiffDays(MyDate a, MyDate b) 23 { 24 return GetAbsDays(b) - GetAbsDays(a); 25 } 26 int main() 27 { 28 int T,n,m,i,j; 29 cin>>T; 30 while(T--){MyDate A,B; 31 int Y,M,D,W; 32 char a,b; 33 scanf("%d-%d-%d",&Y,&M,&D); 34 A.year=Y; 35 A.month=M; 36 A.day=D; 37 B=A; 38 for(;;){ 39 B.year++; 40 if(A.month==2&&A.day==29) 41 { 42 if(!isr(B.year)) continue; 43 } 44 int W2=GetDiffDays(A,B); 45 if(W2%7==0){cout<<B.year<<endl;break;} 46 } 47 } 48 return 0; 49 }
标签:一个 超过 -- hdu mit source date 问题: nbsp
原文地址:http://www.cnblogs.com/zzqc/p/7351357.html