hdu 6010 Daylight Saving Time

题意:就是每年的三月第二个周日和11月第一个周日是特殊的日子,会有时区的变化

思路:XJB判断 

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 const int N=1e5+10;
 5 
 6 
 7 int a[15]={0,31,29,31,30,31,30,31,31,30,31,30,31};
 8 int b[15]={0,31,28,31,30,31,30,31,31,30,31,30,31};
 9 int dd[3000][20][50];
10 
11 void init(){
12     int t=1;
13     for(int i=2007;i<=2100;i++)
14     for(int j=1;j<=12;j++){
15         int xx;
16         if((i%4==0&&i%100!=0)||i%400==0) xx=a[j];
17         else xx=b[j];
18         for(int k=1;k<=xx;k++){
19             dd[i][j][k]=t;
20             t++;
21             if(t==8) t=1;
22         }
23     }
24 }
25 
26 int main(){
27     init();
28     int  t;
29     int k=1;
30     cin>>t;
31     while(t--){
32         int y,m,d;
33         int h,f,s;
34         scanf("%d-%d-%d %d:%d:%d",&y,&m,&d,&h,&f,&s);
35         printf("Case #%d: ",k++);
36         int xx;
37         if(m<3) {
38             cout<<"PST"<<endl;continue;
39         }
40         else if(m>3&&m<11){
41             cout<<"PDT"<<endl;continue;
42         }
43         else if(m>11){
44             cout<<"PST"<<endl;continue;
45         }
46         if((y%4==0&&y%100!=0)||y%400==0) xx=a[m];
47         else xx=b[m];
48         int y1=0,m1=0,d1=0;
49         int y3=0,m3=0,d3=0;
50         int tt=0;
51 
52         int sss=0;
53         for(int i=1;i<=xx;i++){
54             if(dd[y][m][i]==7){
55                 sss++;
56             }
57             if(sss==2&&m==3){
58                 tt=1;y3=y;m3=m;d3=i;break;
59             }
60             else if(sss==1&&m==11){
61                 tt=2;y1=y;m1=m;d1=i;break;
62             }
63         }
64 
65         if(tt==1){
66             if(d>d3) cout<<"PDT"<<endl;
67             else if(d<d3) cout<<"PST"<<endl;
68             else {
69                 int tz=s+f*60+h*60*60;
70               //  cout<<tz<<endl;
71                 if(tz<2*60*60) cout<<"PST"<<endl;
72                 else if(tz>=2*60*60&&tz<3*60*60) cout<<"Neither"<<endl;
73                 else {
74                     cout<<"PDT"<<endl;
75                 }
76             }
77         }
78         else if(tt==2){
79             if(d<d1) cout<<"PDT"<<endl;
80             else if(d>d1) cout<<"PST"<<endl;
81             else {
82                 int tz=s+f*60+h*60*60;
83                 if(tz<1*60*60) cout<<"PDT"<<endl;
84                 else if(tz>=60*60&&tz<2*60*60) cout<<"Both"<<endl;
85                 else cout<<"PST"<<endl;
86             }
87         }
88     }
89 }

 

posted on 2017-09-15 12:58  hhhhx  阅读(218)  评论(0编辑  收藏  举报

导航