Zoj 3785 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.


Author:  ZHOU, Yuchen

Source: The 11th Zhejiang Provincial Collegiate Programming Contest

  

  思路:简单题,一开始没注意数据的访问,各种超,以后做数学题还是要注意找规律,循环节是294,打个表看一下就行了   打表+快速幂

  AC代码如下:

#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
using namespace std;
#define MOD 7
#define LL long long
const int n=300;
int aa[n];
string ss[]={"Saturday","Sunday","Monday","Tuesday","Wednesday",
                "Thursday","Friday"};
LL powerMod(LL n){

    LL tmp=n;
    LL ans=1;
    while(tmp){
        if(tmp%2) ans=(ans*n)%MOD;
        tmp/=2;
        n=(n*n)%MOD;
    }
    return ans;
}



int main(){
    int t;
    int ans=0;
    for(int i=1;i<=n;i++){
        ans+=powerMod(i);
       aa[i]=ans%MOD;
    }

    scanf("%d",&t);
    while(t--){
        int nn;
        scanf("%d",&nn);
        nn%=294;
        //cout<<aa[nn]<<endl;
        cout<<ss[aa[nn]]<<endl;
    }

    return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值