What day is that day?(zoj3785)纪念一下被这道题浪费的3个小时

懒得写题解了,42的加循环a了

代码
#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    long long t;
    scanf("%lld",&t);
    long long n;
    int l;
    int ans;
    int a[45]= {1,4,6,4,3,1,0,
                1,1,4,2,1,6,0,
                1,2,5,1,5,1,0,
                1,4,1,4,4,6,0,
                1,1,3,2,6,1,0,
                1,2,2,1,2,6,0
               };

    for(long long i=1; i<=t; i++)
    {
        scanf("%lld",&n);
        ans=0;
            ans=-(((n-1)/42)%7);
        ans+=7;
        if(n%42==0)n=42;
        else
            n=n%42;
        for(int i=0; i<n; i++)
        {
            ans+=a[i];
        }
        ans+=6;
        ans=ans%7;
        if(ans==0)
            printf("Sunday\n");
        else if(ans==1)
            printf("Monday\n");
        else if(ans==2)
            printf("Tuesday\n");
        else if(ans==3)
            printf("Wednesday\n");
        else if(ans==4)
            printf("Thursday\n");
        else if(ans==5)
            printf("Friday\n");
        else if(ans==6)
            printf("Saturday\n");
    }
    return 0;
}

1 thought on “What day is that day?(zoj3785)纪念一下被这道题浪费的3个小时”

发表评论

电子邮件地址不会被公开。 必填项已用*标注