ZOJ 3785 What day is that day? 循环节找规律
来源:互联网 发布:淘宝云客服质检扣10分 编辑:程序博客网 时间:2024/05/19 19:33
题意:求给定式子%7的结果
暴力求循环节发现 f[1] = f[295], f[2] = f[296]······
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <string>#include <math.h>#include <set>#include <vector>#include <queue>using namespace std;#define N 10000#define ll long longll n, m;#define J 1000ll f[N];void put(ll x){if(x==1)puts("Sunday");if(x==2)puts("Monday");if(x==3)puts("Tuesday");if(x==4)puts("Wednesday");if(x==5)puts("Thursday");if(x==6)puts("Friday");if(x==0)puts("Saturday");}ll quick_pow(ll x, ll y){ll ans = 1;while(y){if(y&1)ans = (ans*x)%7;y >>= 1;x = (x*x)%7;}return ans;}int main(){ll i, j;f[1] = 1;for(i = 2; i < N; i++)f[i] = (f[i-1]+quick_pow(i,i))%7;f[0] = f[294];/*for(i = J+1; i < N; i++){bool yes = true;for(j = 1; j <= J; j++)if(f[j]!=f[j+i-1]){yes = false;break;}if(yes)printf("从第%lld个开始和前J个相同\n",i);}*/ll T;scanf("%lld",&T);while(T--){scanf("%lld",&i);put(f[i%294]);}return 0;}
1 0
- ZOJ 3785 What day is that day? 循环节找规律
- ZOJ 3785What day is that day?(循环节找规律)
- ZOJ 3785 What day is that day? (找规律)
- zoj 3785 What day is that day?(找规律,KMP)
- ZOJ 3785What day is that day?(最小循环节)
- ZOJ3785 What day is that day?(找循环节)
- zoj 3785 What day is that day?
- ZOJ-3785【What day is that day?】
- zoj 3785 What day is that day?
- ZOJ 3785 What day is that day?
- ZOJ 3785 What day is that day?
- ZOJ 3785 What day is that day?
- Zoj 3785 What day is that day?
- ZOJ 3785 - What day is that day?
- zoj-3785-What day is that day?
- zoj 3785 What day is that day?
- What day is that day? ZOJ - 3785
- ZOJ-3785 What day is that day?
- Valid Parentheses
- Struts2 Tomcat class.classLoader.resources.dirContext.docBase赋值造成的DoS及远程代码执行利用!
- java 面试总结
- makefile中的自动化变量
- Android多媒体开发介绍
- ZOJ 3785 What day is that day? 循环节找规律
- 打印1到最大的n位数
- python-安装-linux平台安装方法
- win7 64位 VC 2010下配置OpenCV2.4.4
- 手机WEB页面(HTML5)实现一键拨号及短信发送功能
- 设计模式--状态模式State(行为型)
- 小碎片
- Java实现定时任务的三种方法
- frameset页面,需要整个页面跳转,而不是frameset框架下的页面