标签:pst scan highlight space ret scanf == saving log
先算周几,再模拟
#include <bits/stdc++.h> using namespace std; int GetWeekDay(int y,int m,int d)//0为周一,依此类推 { if(m==1) m=13,y--; if(m==2) m=14,y--; int week=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7; return week; } int t, yy, mm, dd, h, m, s, week; void solve() { if (mm < 3) puts("PST"); else if (mm == 3) { if (week == 7 && dd > 7) { if (h == 2) puts("Neither"); else if (h > 2) puts("PDT"); else if (h < 2) puts("PST"); } else if (dd-week > 7) puts("PDT"); else puts("PST"); } else if (mm > 3 && mm < 11) puts("PDT"); else if (mm == 11) { if (week == 7 && dd <= 7) { if (h < 1) puts("PDT"); else if (h == 1) puts("Both"); else puts("PST"); } else if (dd - week <= 0) puts("PDT"); else puts("PST"); } else puts("PST"); } int main() { scanf("%d", &t); for (int tt = 1; tt <= t; tt++) { scanf("%d-%d-%d %d:%d:%d", &yy, &mm, &dd, &h, &m, &s); week = GetWeekDay(yy, mm, dd); week++; printf("Case #%d: ", tt); solve(); } }
HDU 6010 - Daylight Saving Time
标签:pst scan highlight space ret scanf == saving log
原文地址:http://www.cnblogs.com/nicetomeetu/p/7496028.html