zoj 3785 What day is that day?

时间:2023-03-09 00:56:08
zoj 3785 What day is that day?

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5272

打表找规律。

 #include <cstdio>
#include <cstring>
#include <algorithm>
#define LL long long
using namespace std;
const int mod=;
char g[][]={"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"};
int a[]; LL pow_m(LL a,LL n)
{
LL ret=;
LL temp=a%mod;
while(n)
{
if(n&) ret=(ret*temp)%mod;
temp=temp*temp%mod;
n>>=;
}
return ret;
} int deal(int n)
{
int ans=;
for(int i=; i<=n; i++)
{
ans*=n;
ans%=mod;
}
return ans;
} int main()
{
int t;
scanf("%d",&t);
a[]=;
for(int i=; i<=; i++)
{
a[i]=a[i-]+deal(i);
a[i]%=mod;
}
while(t--)
{
int n;
scanf("%d",&n);
int ans=a[(n%)];
printf("%s\n",g[ans]);
}
return ;
}