codeforces 360 D - Remainders Game

时间:2022-03-17 08:57:38

D - Remainders Game

Description

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 codeforces 360  D - Remainders Game. There are n ancient numbersc1,

c2, ..., cn and Pari has to tell Arya codeforces 360  D - Remainders Gameif 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 codeforces 360  D - Remainders Gamefor any positive integer x?

Note, that codeforces 360  D - Remainders Gamemeans 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.

Sample Input

Input
4 5
2 3 5 12
Output
Yes
Input
2 7
2 3
Output
No

题意:给定n,k,和n个ci。你可以知道x%ci,问是否能确定x%k.
分析:根据中国剩余定理问题就相当于要确定 C 数组整体的最小公倍数 lcm(c)
是否是 K 的倍数,如果是,则能确定输出 yes,否则输出 no.
#include <iostream>
#include<cstdio>
#define LL long long
using namespace std;
int a;
int gcd(LL a,LL b)
{
return b?gcd(b,a%b):a;
}
int main()
{
LL n,k,lcm=;
scanf("%lld%lld", &n, &k);
for(int i=;i<n;i++)
{
scanf("%lld", &a);
lcm = lcm / gcd(lcm, a) * a % k;
}
if(lcm%k==) printf("Yes\n");
else printf("No\n");
return ;
}

 

codeforces 360 D - Remainders Game的更多相关文章

  1. &lbrack;codeforces 360&rsqb;A&period; Levko and Array Recovery

    [codeforces 360]A. Levko and Array Recovery 试题描述 Levko loves array a1, a2, ... , an, consisting of i ...

  2. 套题 codeforces 360

    A题:Opponents 直接模拟 #include <bits/stdc++.h> using namespace std; ]; int main() { int n,k; while ...

  3. codeforces 688D D&period; Remainders Game&lpar;中国剩余定理&rpar;

    题目链接: D. Remainders Game time limit per test 1 second memory limit per test 256 megabytes input stan ...

  4. 【16&period;56&percnt;】【codeforces 687B】Remainders Game

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. codeforces 360 E - The Values You Can Make

    E - The Values You Can Make Description Pari wants to buy an expensive chocolate from Arya. She has  ...

  6. codeforces 360 C

    C - NP-Hard Problem Description Recently, Pari and Arya did some research about NP-Hard problems and ...

  7. codeforces 360 C - NP-Hard Problem

    原题: Description Recently, Pari and Arya did some research about NP-Hard problems and they found the  ...

  8. codeforces&num;687 B&period; Remainders Game

    题意:给出n个数,和一个数p,问你在知道 x%ai  的情况下,能不能确定x%p的值 结论:当n个数的最小公倍数是p的倍数时,可以确定 代码: #include <bits/stdc++.h&g ...

  9. codeforces 360 B

    B - Levko and Array 题目大意:给你你个长度为n的数列a,你最多改变k个值,max{ abs ( a[ i + 1] - a[ i ] ) } 的最小值为多少. 思路:这个题很难想到 ...

随机推荐

  1. Android之常用Git命令

    Android之常用Git命令 代码修改后提交步骤:git status:查看代码修改状态git diff:查看代码修改细节,也能看代码空格git add . :添加新加入的代码git commit ...

  2. 上海SAP代理商 服装行业ERP系统 达策SAP金牌代理商

    上海SAP代理商 服装行业ERP系统 达策SAP金牌代理商上海达策公司的前身是上海InfoPower技术有限公司,该公司在中国ERP软件的销售和服务长达20年.在2005年4月上海达策正式成立,致成立 ...

  3. Cheatsheet&colon; 2015 03&period;01 ~ 03&period;31

    Web The Architecture of Algolia's Distributed Search Network No promises: asynchronous JavaScript wi ...

  4. 三道JS试题(遍历、创建对象、URL解析)

    最近在网上看到了三道不错的JS试题,还是很基础(一直认为学好前端基本功很重要...),现在记录如下: 原帖地址:http://www.w3cfuns.com/forum.php?mod=viewthr ...

  5. 深入理解JAVA序列化

    如果你只知道实现 Serializable 接口的对象,可以序列化为本地文件.那你最好再阅读该篇文章,文章对序列化进行了更深一步的讨论,用实际的例子代码讲述了序列化的高级认识,包括父类序列化的问题.静 ...

  6. JavaScript中涉及得运算符以及运算符的优先级

    在js中主要有三种运算符:算术运算符,逻辑与比较运算符,位运算符.在着三种运算符中,最常见的应该是算术与比较运算符,位运算符比较少见一些 *说到了运算符,就不得不说运算符的优先级.下面我来列一下这些运 ...

  7. 笔记:MyBatis XML配置-typeAliases 内建别名表

    别名 映射的类型 _byte byte _long long _short short _int int _integer int _double double _float float _boole ...

  8. &lbrack;LeetCode&rsqb; Letter Case Permutation 字母大小写全排列

    Given a string S, we can transform every letter individually to be lowercase or uppercase to create ...

  9. springboot学习小记

    思维导图:https://www.edrawsoft.cn/viewer/public/s/72a06689197636 1.springboot是一个快速整合第三方框架,简化XML配置完全采用注解化 ...

  10. Aizu2130-Billion Million Thousand-dp

    用dp求出最大的表达,再用dp求出.//然而并没有想出来 #include <cstdio> #include <string> #include <algorithm& ...