Codeforces Round #360 (Div. 2) 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
In the first sample, Arya can understand
because 5 is one of the ancient numbers.
In the second sample, Arya can't be sure what
is. For example 1 and 7 have the same remainders after dividing by 2 and 3, but they differ in remainders after dividing by 7.
题意:给你n个数,一个k;可以告诉你xmod ci的值;求x%k是否唯一;
思路:根据中国剩余定理,如果中国剩余定理有解x,另外一个解为x+lcm(c0,c1...cn);
所以lcm%k==0;
#include<bits/stdc++.h>
using namespace std;
#define ll __int64
#define mod 1000000007
#define pi (4*atan(1.0))
const int N=1e3+,M=1e6+,inf=1e9+;
ll gcd(ll a,ll b)
{
return b==?a:gcd(b,a%b);
}
int main()
{
ll x,y,z,i,t;
ll lcm=;
scanf("%lld%lld",&x,&y);
for(i=;i<x;i++)
{
scanf("%lld",&z);
lcm=z*lcm/gcd(z,lcm);
lcm%=y;
}
if(lcm==)
printf("Yes\n");
else
printf("No\n");
return ;
}
Codeforces Round #360 (Div. 2) D. Remainders Game的更多相关文章
- Codeforces Round #360 (Div. 2) D. Remainders Game 数学
D. Remainders Game 题目连接: http://www.codeforces.com/contest/688/problem/D Description Today Pari and ...
- Codeforces Round #360 (Div. 2) D. Remainders Game 中国剩余定理
题目链接: 题目 D. Remainders Game time limit per test 1 second memory limit per test 256 megabytes 问题描述 To ...
- Codeforces Round #360 (Div. 1) D. Dividing Kingdom II 暴力并查集
D. Dividing Kingdom II 题目连接: http://www.codeforces.com/contest/687/problem/D Description Long time a ...
- Codeforces Round #360 (Div. 2) C. NP-Hard Problem 水题
C. NP-Hard Problem 题目连接: http://www.codeforces.com/contest/688/problem/C Description Recently, Pari ...
- Codeforces Round #360 (Div. 2) B. Lovely Palindromes 水题
B. Lovely Palindromes 题目连接: http://www.codeforces.com/contest/688/problem/B Description Pari has a f ...
- Codeforces Round #360 (Div. 2) A. Opponents 水题
A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...
- Codeforces Round #360 (Div. 1)A (二分图&dfs染色)
题目链接:http://codeforces.com/problemset/problem/687/A 题意:给出一个n个点m条边的图,分别将每条边连接的两个点放到两个集合中,输出两个集合中的点,若不 ...
- Codeforces Round #360 (Div. 1) D. Dividing Kingdom II 并查集求奇偶元环
D. Dividing Kingdom II Long time ago, there was a great kingdom and it was being ruled by The Grea ...
- Codeforces Round #360 (Div. 2) E. The Values You Can Make DP
E. The Values You Can Make Pari wants to buy an expensive chocolate from Arya. She has n coins, ...
随机推荐
- Python3.6编译安装以及python开发之virtualenv与virtualenvwrapper
Python3.6编译安装 下载python源码包 先到安装目录 cd /opt 下载源码包 wget https://www.python.org/ftp/python/3.6.2/Python-3 ...
- spring Bean装配的几种方式简单介绍
Spring容器负责创建应用程序中的bean同时通过ID来协调这些对象之间的关系.作为开发人员,我们需要告诉Spring要创建哪些bean并且如何将其装配到一起. spring中bean装配有两种方式 ...
- B-、B+、B*树
B-树:多路搜索树,每个结点存储M/2到M个关键字,非叶子结点存储指向关键字范围的子结点:所有关键字在整颗树中出现,且只出现一次,非叶子结点可以命中: B+树:在B-树基础上,为叶子结点增加链表指针, ...
- Junit 并行执行测试
从Junit4.7开始可以并行运行测试. 必须设置parallel 参数,可以改变threadCount或useUnlimitedThreads属性. 测试中指定了parallel,项目使用的是 JU ...
- vue——学习笔记
1.vue需要在dom加载完成之后实现实例化 eg: window.onload = function(){ new Vue({ el: '#editor', data: { input: '# he ...
- 爬虫——请求库之requests
阅读目录 一 介绍 二 基于GET请求 三 基于POST请求 四 响应Response 五 高级用法 一 介绍 #介绍:使用requests可以模拟浏览器的请求,比起之前用到的urllib,reque ...
- 磁盘结构,平均寻道时间,平均延迟时间,虚拟内存与MMU
首先了解一下磁盘:磁盘低速的原因是因为它一种机械装置,在磁盘中有一个或多个金属盘片,它们以5400,7200或10800rpm(RPM =revolutions per minute 每分钟多少转 ) ...
- C# DateTime 获取时间方法,网上收集
DateTime dt = DateTime.Now; //当前时间 DateTime startWeek = dt.AddDays( - Convert.ToInt32(dt.DayOfWeek.T ...
- springCloud--1
电影微服务是服务消费者,用户微服务是服务提供者. Springcloud对eureka的支持很好,eureka本身是一个基于REST的服务, Eureka里面有一个注册表,Application Cl ...
- JS正则表达式从入门到入土(6)—— 贪婪模式与非贪婪模式
贪婪模式 之前说了正则的量词,但是量词会带来一个到底该匹配哪个的问题. 如下正则表达式: \d{3,6} 这个正则表达式是匹配3到6个数字,但是当这个正则表达式被用来匹配12345678这个字符串,到 ...