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 ;
}
zoj 3785 What day is that day?的更多相关文章
- ZOJ 3785 What day is that day?(今天是星期几?)
Description 题目描述 It's Saturday today, what day is it after 11 + 22 + 33 + ... + NN days? 今天是星期六,11 + ...
- zoj 3785 What day is that day? (打表找规律)
题目 思路:比赛的时候有想过找循环节,但是,打表打错了. 后来,看着过了挺多人,就急了, 看了一下别人的时间 耗时都挺长的,就以为不是找规律, 没想到真是找规律,不过,这个题的数据可能挺大的. AC代 ...
- 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 da ...
- 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 ...
- 【ZOJ】3785 What day is that day? ——浅谈KMP在ACM竞赛中的暴力打表找规律中的应用
转载请声明出处:http://www.cnblogs.com/kevince/p/3887827.html ——By Kevince 首先声明一下,这里的规律指的是循环,即找到最小循环周期. 这 ...
- 【ZOJ】3785 What day is that day? ——KMP 暴力打表找规律
转自:http://www.cnblogs.com/kevince/p/3887827.html 首先声明一下,这里的规律指的是循环,即找到最小循环周期. 这么一说大家心里肯定有数了吧,“不就是nex ...
- 2014 Super Training #4 G What day is that day? --两种方法
原题: ZOJ 3785 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3785 题意:当天是星期六,问经过1^1+2^2+ ...
- ZOJ People Counting
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ 3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...
- ZOJ 3686 A Simple Tree Problem
A Simple Tree Problem Time Limit: 3 Seconds Memory Limit: 65536 KB Given a rooted tree, each no ...
随机推荐
- docker安装lnmp 环境
docker基础知识请转 docker中文文档:http://docker-doc.readthedocs.io/zh_CN/latest/index.html docker英文文档: https:/ ...
- Linux TCP队列相关参数的总结
作者:阿里技术保障锋寒 原文:https://yq.aliyun.com/articles/4252 摘要: 本文尝试总结TCP队列缓冲相关的内核参数,从协议栈的角度梳理它们,希望可以更容易的理解和记 ...
- Quartz简单使用
官方的Quartz会提供例子的,例子看个前三四个感觉就够用了,主要就是起Timer的作用,但是比timer稳定,而且功能更全. UpdateClientTimer.task(ClearJob.clas ...
- Apache POI解析excel文件
这里需要用到poi.jar和poi-ooxml.jar 没有的可以去http://mvnrepository.com/下载 import org.apache.poi.POIXMLDocument; ...
- poj 1201 Interval (查分约束)
/* 数组开大保平安. 查分约束: 输入的时候维护st和end 设每个点取元素di个 维护元素个数前缀和s Sbi-Sai-1>=ci 即:建立一条从ai-1到bi的边 权值为ci 表示ai到b ...
- codevs3304水果姐逛水果街
/* 线段树开到*4 *4 *4 *4 ! 维护 4个值 区间最大值 区间最小值 从左往右跑最大收益 从右往左跑最大收益 */ #include<iostream> #include< ...
- 命令行命令mvn
在cmd命令行敲击mvn clean install 默认读取的maven配置文件是D:\software\apache-maven-3.2.1\conf\settings.xml 这个文件里面配置有 ...
- YII框架开发一个项目的通用目录结构
YII框架开发一个项目的通用目录结构: 3 testdrive/ 4 index.php Web 应用入口脚本文件 5 assets/ 包含公开的资源文件 6 css/ 包含 CSS 文件 7 ima ...
- 【转】 iOS使用AVFoundation实现二维码扫描
原文:http://strivingboy.github.io/blog/2014/11/08/scan-qrcode/ 关于二维码扫描有不少优秀第三方库如: ZBar SDK 里面有详细的文档,相应 ...
- hibernate_validator_02
三种不通的注解 1. 字段级(field level) 约束 package com.mycompany; import javax.validation.constraints.NotNull; p ...