首页 > 代码库 > HDU6010 Daylight Saving Time
HDU6010 Daylight Saving Time
1 /* 2 HDU6010 Daylight Saving Time 3 http://acm.hdu.edu.cn/showproblem.php?pid=6010 4 模拟 5 题意:算当前时间是否是夏令时 6 7 */ 8 #include <cstdio> 9 #include <algorithm> 10 using namespace std; 11 //#define test 12 int yy,mm,dd,h,m,s; 13 void read() 14 { 15 scanf("%d",&yy); 16 getchar(); 17 scanf("%d",&mm); 18 getchar(); 19 scanf("%d",&dd); 20 getchar(); 21 scanf("%d",&h); 22 getchar(); 23 scanf("%d",&m); 24 getchar(); 25 scanf("%d",&s); 26 #ifdef test 27 printf("%d-%d-%d %d:%d:%d\n",yy,mm,dd,h,m,s); 28 29 #endif 30 } 31 int main() 32 { 33 int t; 34 //freopen("in.in","r",stdin); 35 scanf("%d",&t); 36 for(int l=1;l<=t;l++) 37 { 38 int day=0; 39 printf("Case #%d: ",l); 40 read(); 41 if(mm>=4 && mm<=10) 42 { 43 printf("PDT\n"); 44 continue; 45 } 46 else if(mm==1 || mm==2 || mm==12) 47 { 48 printf("PST\n"); 49 continue; 50 } 51 else if(mm==3) 52 { 53 day=0; 54 day+=(yy-2007)*365; 55 //printf("day:%d\n",day); 56 if(yy!=2007) 57 day+=(yy-2008)/4+1; 58 //printf("day:%d\n",day); 59 if(yy==2100) 60 day--; 61 day+=59; 62 int day1=day+1; 63 //printf("day:%d\n",day); 64 int ss1=day1%7; 65 int fenjie; 66 if(ss1==0) 67 fenjie=8; 68 else 69 fenjie=15-ss1; 70 #ifdef test 71 //fenjie++; 72 printf("ss1:%d\n",ss1); 73 printf("fenjie:%d\n",fenjie); 74 #endif 75 if(dd<fenjie) 76 { 77 printf("PST\n"); 78 continue; 79 } 80 else if(dd>fenjie) 81 { 82 printf("PDT\n"); 83 continue; 84 } 85 else 86 { 87 if(h==2) 88 { 89 printf("Neither\n"); 90 continue; 91 } 92 else if(h>2) 93 { 94 printf("PDT\n"); 95 continue; 96 } 97 else 98 { 99 printf("PST\n"); 100 continue; 101 } 102 } 103 104 } 105 else if(mm==11) 106 { 107 day+=(yy-2007)*365; 108 if(yy!=2007) 109 day+=(yy-2008)/4+1; 110 if(yy==2100) 111 day--; 112 day+=304; 113 int day1=day+1; 114 int ss1=day1%7; 115 int fenjie; 116 if(ss1==0) 117 fenjie=1; 118 else 119 fenjie=8-ss1; 120 #ifdef test 121 //fenjie++; 122 printf("ss1:%d\n",ss1); 123 printf("fenjie:%d\n",fenjie); 124 #endif 125 if(dd<fenjie) 126 { 127 printf("PDT\n"); 128 continue; 129 } 130 else if(dd>fenjie) 131 { 132 printf("PST\n"); 133 continue; 134 } 135 else 136 { 137 if(h==1) 138 { 139 printf("Both\n"); 140 continue; 141 } 142 else if(h<1) 143 { 144 printf("PDT\n"); 145 continue; 146 } 147 else 148 { 149 printf("PST\n"); 150 continue; 151 } 152 } 153 } 154 } 155 156 return 0; 157 }
HDU6010 Daylight Saving Time
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。