请求降橙
查看原帖
请求降橙
1074084
asd890123楼主2024/8/3 12:29

本题的思维难度和代码量就一个纯模拟的难度,完全没有到T3大模拟的难度,至少我觉得我的代码是这样,my code:

#include <iostream>

int Month[] = {-1,31,-1,31,30,31,30,31,31,30,31,30,31};

int GetDay(int month,int year){

    if (month == 2){

        if (year % 4 == 0){

            if (year % 100 == 0) return year % 400 == 0 ? 29 : 28;
            return 29;

        }
        return 28;

    }

    return Month[month];
}

int main(){

    #ifndef ONLINE_JUDGE
        freopen("P2655.in","r",stdin);
    #endif

    int T;

    for (scanf("%d",&T);T--;){

        long long sec;
        int len,year,month,date,hour,mins;

        scanf("%d%d%d%d%d%d%lld",&len,&year,&month,&date,&hour,&mins,&sec);
        int MaxLen = (1L << (len - 1)) - 1;
        sec += MaxLen;
        mins += sec / 60;
        sec %= 60;
        hour += mins / 60;
        mins %= 60;
        date += hour / 24;
        hour %= 24;
        while (date > GetDay(month,year)){

            date -= GetDay(month,year);
            month++;
            if (month > 12) month -= 12,year++;

        }
        printf("%d %d %d %d %d %lld\n",year,month,date,hour,mins,sec);

    }

    return 0;
}
2024/8/3 12:29
加载中...