codeforces 688D D. Remainders Game(中国剩余定理)
题目链接:
1 second
256 megabytes
standard input
standard output
Today Pari and Arya are playing a game called Remainders.
Pari chooses two positive integer x and k, and tells Arya k but not x. Arya have to find the value . There are n ancient numbers c1, c2, ..., cn and Pari has to tell Arya
if Arya wants. Given k and the ancient values, tell us if Arya has a winning strategy independent of value of x or not. Formally, is it true that Arya can understand the value
for any positive integer x?
Note, that means the remainder of x after dividing it by y.
The first line of the input contains two integers n and k (1 ≤ n, k ≤ 1 000 000) — the number of ancient integers and value k that is chosen by Pari.
The second line contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 1 000 000).
Print "Yes" (without quotes) if Arya has a winning strategy independent of value of x, or "No" (without quotes) otherwise.
4 5
2 3 5 12
Yes
2 7
2 3
No 题意: 给出c1,c2,...cn,问对于任何一个正整数x,给出x%c1,x%c2,...的值x%k的值是否确定; 思路: 中国剩余定理,给个链接:传送门 AC代码:
//#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio> using namespace std;
#define Riep(n) for(int i=1;i<=n;i++)
#define Riop(n) for(int i=0;i<n;i++)
#define Rjep(n) for(int j=1;j<=n;j++)
#define Rjop(n) for(int j=0;j<n;j++)
#define mst(ss,b) memset(ss,b,sizeof(ss));
typedef long long LL;
template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<''||CH>'';F= CH=='-',CH=getchar());
for(num=;CH>=''&&CH<='';num=num*+CH-'',CH=getchar());
F && (num=-num);
}
int stk[], tp;
template<class T> inline void print(T p) {
if(!p) { puts(""); return; }
while(p) stk[++ tp] = p%, p/=;
while(tp) putchar(stk[tp--] + '');
putchar('\n');
} const LL mod=1e9+;
const double PI=acos(-1.0);
const LL inf=1e18;
const int N=1e6+;
const int maxn=;
const double eps=1e-; int n,k;
LL c[N];
LL gcd(LL a,LL b)
{
if(b==)return a;
return gcd(b,a%b);
}
int main()
{
read(n);read(k);
LL lcm=;
for(int i=;i<=n;i++)
{
read(c[i]);
lcm=c[i]/gcd(lcm,c[i])*lcm;
lcm%=k;
}
if(lcm==)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return ;
}
codeforces 688D D. Remainders Game(中国剩余定理)的更多相关文章
- E - Two Arithmetic Progressions(CodeForces - 710D)(拓展中国剩余定理)
You are given two arithmetic progressions: a1k + b1 and a2l + b2. Find the number of integers x such ...
- Educational Codeforces Round 16 D. Two Arithmetic Progressions (不互质中国剩余定理)
Two Arithmetic Progressions 题目链接: http://codeforces.com/contest/710/problem/D Description You are gi ...
- Remainders Game (中国剩余定理)
题意:已知k和一个集合C={c1,c2,c3....cn},问是否有满足集合C的中国剩余定理的解x,使x%k的值唯一确定. 数学知识: #include<iostream> #includ ...
- codeforces 360 D - Remainders Game
D - Remainders Game Description Today Pari and Arya are playing a game called Remainders. Pari choos ...
- ACM/ICPC 之 中国剩余定理+容斥原理(HDU5768)
二进制枚举+容斥原理+中国剩余定理 #include<iostream> #include<cstring> #include<cstdio> #include&l ...
- 中国剩余定理(Chinese Remainder Theorem)
我理解的中国剩余定理的含义是:给定一个数除以一系列互素的数${p_1}, \cdots ,{p_n}$的余数,那么这个数除以这组素数之积($N = {p_1} \times \cdots \tim ...
- 51nod1079(中国剩余定理)
题目链接: http://www.51nod.com/onlineJudge/user.html#!userId=21687 题意: 中文题诶~ 思路: 本题就是个中国剩余定理模板题,不过模拟也可以过 ...
- HDU 5446 中国剩余定理+lucas
Unknown Treasure Time Limit: 1500/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Other ...
- poj1006生理周期(中国剩余定理)
/* 中国剩余定理可以描述为: 若某数x分别被d1..….dn除得的余数为r1.r2.….rn,则可表示为下式: x=R1r1+R2r2+…+Rnrn+RD 其中R1是d2.d3.….dn的公倍数,而 ...
随机推荐
- XV6文件系统
文件系统 文件系统的目的是组织和存储数据,典型的文件系统支持用户和程序间的数据共享,并提供数据持久化的支持(即重启之后数据仍然可用). xv6 的文件系统中使用了类似 Unix 的文件,文件描述符,目 ...
- You Are the One (区间DP)
The TV shows such as You Are the One has been very popular. In order to meet the need of boys who ar ...
- 谢孟军:The State of Go | ECUG Con 精粹系列
本月 17 日,Go 1.8 版本火热发布.相较于以往的版本,Go 1.8 具体有哪些新的特性呢?想必这是不少 Gopher 们热切关注和讨论的问题.作为著名的Golang 布道者,Gopher Ch ...
- [codeforces722C]Destroying Array
[codeforces722C]Destroying Array 试题描述 You are given an array consisting of n non-negative integers a ...
- 解决Flex4在Module里调用PopUpManager报错问题
项目大了 就需要用到Module, 发现在一个Module里边, 和普通应用里一样popup一个组件的时候, 总是会报错. 这个在Flex3的时候也会出现, 会报样式错误 所以就想到了addPopUp ...
- centos 中找不到 php-config
两种解决方式: 1.CentOS6 PHP extension install: Cannot find php-config. Please use --with-php-config=PATH 2 ...
- 学习日常笔记<day16>mysql加强
1.数据约束 1.1什么是数据约束 对用户操作表的数据进行约束 1.2 默认值 作用:当永辉对使用默认值的字段不插入值的时候,就使用默认值 注意: 1)对默认值字段插入null是可以的 2)对默认值字 ...
- webpack体积优化篇二(GZ压缩)
这里我列举几个常用的能够用于减少包体大小的插件,我们可以根据项目需求选择性的使用: compression-webpack-plugin :该插件能够将资源文件压缩为.gz文件,并且根据客户端的需求按 ...
- 有多个git项目要用多个秘钥
在~/.ssh文件夹下新建文件config,格式例如以下 Host "authmanage" HostName "code.csdn.net" User &qu ...
- Java入门 第一季第五章 编程练习解析
这是我学习慕课网Java课程的笔记.原视频链接为:http://www.imooc.com/learn/85 5-1 基本写法 自己主动补全快捷键:alt + / 5-2 输入输出 使用Scanner ...