HDU 5690 All X 暴力循环节
分析:暴力找循环节就好了
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long LL;
const int N=1e4+;
const int INF=0x3f3f3f3f;
const LL mod=1e9+;
bool vis[N];
int cur[N*];
int main()
{
int T,cas=;
scanf("%d",&T);
while(T--){
LL x,m,k,c;
scanf("%I64d%I64d%I64d%I64d",&x,&m,&k,&c);
LL t=,cnt=;
bool flag=;
memset(vis,,sizeof(vis));
for(;;++cnt){
t=t*+x;
if(vis[t%k]){flag=;break;}
vis[t%k]=;cur[cnt]=t%k;
t%=k;
}
if(flag){m%=cnt;if(m==)m=cnt;}
printf("Case #%d:\n",++cas);
if(cur[m]==c)printf("Yes\n");
else printf("No\n");
}
return ;
}
HDU 5690 All X 暴力循环节的更多相关文章
- "红色病毒"问题 HDU 2065 递推+找循环节
题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=2065 递推类题目, 可以考虑用数学方法来做, 但是明显也可以有递推思维来理解. 递推的话基本就是状态 ...
- HDU 5451——递推式&&循环节
题意 设 $y = (5+2\sqrt 6)^{1+2^x}$,给出 $x, M$($0\leq x \leq 2^{32}, M \leq 46337$),求 $[y]\%M$. 分析 由通项推递推 ...
- hdu 1005 Number Sequence(循环节)
题意,f(1)=1,f(2)=1,f(n)=a*f(n-1)+b*f(n-2),求f(n)%7 这个题可能数据不够严谨,所以有些错误的做法也可以通过,比如7 7 50,应该输出0而不是1 解:找到关键 ...
- hdu 3746 Cyclic Nacklace KMP循环节
Cyclic Nacklace 题意:给一个长度为Len( 3 <= Len <= 100000 )的英文串,问你在字符串后面最少添加几个字符可以使得添加后的串为周期串? Sample I ...
- Period - HDU 1358(next求循环节)
题目大意:有一个长N的字符串,如果前缀Ni是一个完全循环的串(循环次数大于1),输出Ni和它循环了多少次. 分析:输入next的应用,求出来next数组直接判断Ni是否是完全的循环就行了,也就是N ...
- hdu 3307 简单的指数循环节
#include<stdio.h>#include<string.h>#include<algorithm>#define LL __int64using name ...
- hdu 4291(矩阵+暴力求循环节)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4291 思路:首先保留求出循环节,然后就是矩阵求幂了. #include<iostream> ...
- HDU 5690——All X——————【快速幂 | 循环节】
All X Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submi ...
- HDU 3746 - Cyclic Nacklace & HDU 1358 - Period - [KMP求最小循环节]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3746 Time Limit: 2000/1000 MS (Java/Others) Memory Li ...
随机推荐
- To change the sharepoint CA port
Set-SPCentralAdministration -Port <port number> to fix the error: Got this error: Failed to re ...
- ubuntu下安装GTK过程
GTK的安装过程比较繁琐,以前也安装过,但没有记录下来,Google一下记录下来备用. 利用此方法成功在ubuntu12.04下安装GTK 2.24.10 1.安装gcc/g++/gdb/make 等 ...
- python 开发webService
最近在学习用python 开发webservice,费了半天时间把环境搭好,记录下具体过程,以备后用. 首先系统上要有python.其次要用python进行webservice开发,还需要一些库: 1 ...
- SVN 迁移
前段时间公司的SVN服务器做升级,需要做SVN迁移,百度谷歌了解了大概,在测试环境试了一下,没什么问题,然后改在正式环境做,迁移成功.之前用的是1.6,我看了下官网有1.8,征得同意后就直接升级加迁移 ...
- linux 下安装JDK1.7
安装JDK1.7 1. 打开网址http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u5-downloads-1591156.ht ...
- window live writer的曲折安装过程
之前一直使用windows live writer2012写日志,由于之前重装了系统,所以需要重新安装writer,本以为是一个很简单的过程,你就是安装个软件吗.... 然而事实是... ...
- 【斜率DP】BZOJ 3675:[Apio2014]序列分割
3675: [Apio2014]序列分割 Time Limit: 40 Sec Memory Limit: 128 MBSubmit: 1066 Solved: 427[Submit][Statu ...
- What is an eigenvector of a covariance matrix?
What is an eigenvector of a covariance matrix? One of the most intuitive explanations of eigenvector ...
- properties配置文件中文乱码解决方法
方法1 properties文件的格式一般为: ROOT=http://localhost:8080/BNCAR2/ ROOTPATH=E:/ws2/BNCAR2/rel/ MALL_PARTS_ ...
- Unix/Linux下如何使用Vi编辑器
vi 的工作模式 Vi 在初始启动后首先进入编辑模式,这时用户可以利用一些预先定义的按键来移动光标.删除文字. 复制或粘贴文字等.这些按键均是普通的字符,例如 l 是向右移动光标,相当于向右箭头键,k ...