被坑死了,居然是294一个循环!!!打表吧,能发现规律的,有了规律,这题就特别简单
有一个小知识点
(a + b + c)%mod = a%mod + b%mod +c%mod;
(a * b * c)%mod = (a%mod)*(b%mod)*(c%mod);
#include <iostream>
using namespace std;
int a[300];
char d[8][10] = {"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"};
void init()
{
int ans,sum=0;
for(int i=1;i<=294;i++)
{
ans=1;
for(int j=1;j<=i;j++)
{
ans = (ans*(i%7))%7;
}
sum = (sum + ans)%7;
a[i] = sum % 7;
}
}
int main()
{
int n;
int t;
cin>>t;
init();
while(t--)
{
cin>>n;
int m = n%294;
cout<<d[a[m]]<<endl;
}
return 0;
}