What day is that day in zoj 3785?

Source: Internet
Author: User

Http://acm.zju.edu.cn/onlinejudge/showProblem.do? Problemid = 5272

Create a table to find the rule.

 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #define LL long long 5 using namespace std; 6 const int mod=7; 7 char g[][10]={"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"}; 8 int a[300]; 9 10 LL pow_m(LL a,LL n)11 {12     LL ret=1;13     LL temp=a%mod;14     while(n)15     {16         if(n&1) ret=(ret*temp)%mod;17         temp=temp*temp%mod;18         n>>=1;19     }20     return ret;21 }22 23 int deal(int n)24 {25     int ans=1;26     for(int i=1; i<=n; i++)27     {28         ans*=n;29         ans%=mod;30     }31     return ans;32 }33 34 int main()35 {36     int t;37     scanf("%d",&t);38     a[0]=0;39     for(int i=1; i<=294; i++)40     {41         a[i]=a[i-1]+deal(i);42         a[i]%=mod;43     }44     while(t--)45     {46         int n;47         scanf("%d",&n);48         int ans=a[(n%294)];49         printf("%s\n",g[ans]);50     }51     return 0;52 }
View code

 

What day is that day in zoj 3785?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.