码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 6010 - Daylight Saving Time

时间:2017-09-08 20:37:30      阅读:210      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!