ZOJ3785 What day is that day?(找循环节)

What day is that day?

Time Limit: 2 Seconds       Memory Limit: 65536 KB

It's Saturday today, what day is it after 11 + 22 + 33 + ... + NN days?

Input

There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:

There is only one line containing one integer N (1 <= N <= 1000000000).

Output

For each test case, output one string indicating the day of week.

Sample Input
2
1
2
Sample Output
Sunday
Thursday
Hint

A week consists of Sunday, Monday, Tuesday, Wednesday, Thursday, Friday and Saturday.



底数%7 指数为1,2…时找到的循环

0|0
1|1
2|124
3|132645
4|142
5|154623
6|16

将(i^i)%7打表得到42一循环的数列

将ans打表转换为星期制输出


#include<stdio.h>
int t[300]={0,1,5,4,1,4,5,5,6,0,4,6,0,6,6,0,2,0,1,6,0,0,1,5,6,3,0,6,6,0,1,4,6,5,6,6,0,2,4,5,0,6,6,0,4,3,0,3,4,4,5,6,3,5,6,5,5,6,1,6,0,5,6,6,0,4,5,2,6,5,5,6,0,3,5,4,5,5,6,1,3,4,6,5,5,6,3,2,6,2,3,3,4,5,2,4,5,4,4,5,0,5,6,4,5,5,6,3,4,1,5,4,4,5,6,2,4,3,4,4,5,0,2,3,5,4,4,5,2,1,5,1,2,2,3,4,1,3,4,3,3,4,6,4,5,3,4,4,5,2,3,0,4,3,3,4,5,1,3,2,3,3,4,6,1,2,4,3,3,4,1,0,4,0,1,1,2,3,0,2,3,2,2,3,5,3,4,2,3,3,4,1,2,6,3,2,2,3,4,0,2,1,2,2,3,5,0,1,3,2,2,3,0,6,3,6,0,0,1,2,6,1,2,1,1,2,4,2,3,1,2,2,3,0,1,5,2,1,1,2,3,6,1,0,1,1,2,4,6,0,2,1,1,2,6,5,2,5,6,6,0,1,5,0,1,0,0,1,3,1,2,0,1,1,2,6,0,4,1,0,0,1,2,5,0,6,0,0,1,3,5,6,1,0,0};
int main()
{
    int cas,n,ans;
    scanf("%d",&cas);
    while(cas--)
    {
        scanf("%d",&n);
        ans=t[n%294];
        if(ans==1)
            printf("Sunday\n");
        else if(ans==2)
            printf("Monday\n");
        else if(ans==3)
            printf("Tuesday\n");
        else if(ans==4)
            printf("Wednesday\n");
        else if(ans==5)
            printf("Thursday\n");
        else if(ans==6)
            printf("Friday\n");
        else
            printf("Saturday\n");
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值