D. Remainders Game
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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).

Output

Print "Yes" (without quotes) if Arya has a winning strategy independent of value of x, or "No" (without quotes) otherwise.

Examples
input
4 5
2 3 5 12
output
Yes
input
2 7
2 3
output
No
Note

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的更多相关文章

  1. Codeforces Round #360 (Div. 2) D. Remainders Game 数学

    D. Remainders Game 题目连接: http://www.codeforces.com/contest/688/problem/D Description Today Pari and ...

  2. Codeforces Round #360 (Div. 2) D. Remainders Game 中国剩余定理

    题目链接: 题目 D. Remainders Game time limit per test 1 second memory limit per test 256 megabytes 问题描述 To ...

  3. 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 ...

  4. Codeforces Round #360 (Div. 2) C. NP-Hard Problem 水题

    C. NP-Hard Problem 题目连接: http://www.codeforces.com/contest/688/problem/C Description Recently, Pari ...

  5. Codeforces Round #360 (Div. 2) B. Lovely Palindromes 水题

    B. Lovely Palindromes 题目连接: http://www.codeforces.com/contest/688/problem/B Description Pari has a f ...

  6. Codeforces Round #360 (Div. 2) A. Opponents 水题

    A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...

  7. Codeforces Round #360 (Div. 1)A (二分图&dfs染色)

    题目链接:http://codeforces.com/problemset/problem/687/A 题意:给出一个n个点m条边的图,分别将每条边连接的两个点放到两个集合中,输出两个集合中的点,若不 ...

  8. 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 ...

  9. 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, ...

随机推荐

  1. Spring整合JUnit4进行AOP单元测试的时候,报:"C:\Program Files\Java\jdk1.8.0_191\bin\java.exe" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2018.3\lib\idea_rt.jar=64

    错误代码 "C:\Program Files\Java\jdk1.8.0_191\bin\java.exe" -ea -Didea.test.cyclic.buffer.size= ...

  2. 爬虫之FileCookieJar

    简介 虽然CookieJar模块能够做到给请求设置cookie,但是它的cookie是保存在内存里的,每次用都需要重新设置, 这就衍生了一个它的子类---FileCookieJar,它可以将cooki ...

  3. 爬虫之Xpath详解

    XPath介绍 XPath 是一门在 XML 文档中查找信息的语言.XPath 可用来在 XML 文档中对元素和属性进行遍历. XPath 是 W3C XSLT 标准的主要元素,并且 XQuery 和 ...

  4. HttpRunnerManager平台异步生成及展示代码覆盖率报告

    ant+jacoco+jenkins+HttpRunnerManager代码覆盖率统计平台搭建 实现思路通过jenkins构建,并使用HttpRunnerManager异步实现报告更新与展示. 现在整 ...

  5. IDOC 实例测试

    这份文档主要是自己学习IDOC的一些练习过程及心得,可能讲的不全面,但应该可以帮助大家了解IDOC的一些工作方式. IDOC或者说是ALE,事实上,是SAP用于分布和集成数据的一种方式.所以,我个人就 ...

  6. MongoDB的分布式部署

    一.分片的概念 分片(sharding)是指根据片键,将数据进行拆分,使其落在不同的机器上的过程.如此一来,不需要功能,配置等强大的机器,也能储存大数据量,处理更高的负载. 二.分片的原理和思想 Mo ...

  7. Font: a C++ class

    Font: a C++ class        This class is used in Fractal Generator.    Avi Examples The header fileFon ...

  8. Mac使用操作

    快捷键退出程序:Command + Q 快捷键关闭窗口:Command + W(关闭程序的窗口不一定是退出程序) 单击左上角黑苹果,菜单里面有强制退出 Finder菜单的偏好设置,高级设置菜单里面可以 ...

  9. 进程 、进程组、会话、控制终端之间的关系 (转载 http://blog.csdn.net/yh1548503342/article/details/41891047)

    一个进程组可以包含多个进程 进程组中的这些进程之间不是孤立的,他们彼此之间或者存在者父子.兄弟关系,或者在功能有相近的联系. 那linux为什么要有进程组呢?其实提供进程组就是方便管理这些进程.假设要 ...

  10. phpcms发布到服务器修改

    请进行以下步骤的修改: 1.修改/caches/configs/system.php里面所有和域名有关的,把以前的老域名修改为新域名就可以了. 2.进行后台设置->站点管理 对相应的站点的域名进 ...