codeforces 360 D - Remainders Game
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 . There are n ancient numbersc1,
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.
Sample Input
4 5
2 3 5 12
Yes
2 7
2 3
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的更多相关文章
- [codeforces 360]A. Levko and Array Recovery
[codeforces 360]A. Levko and Array Recovery 试题描述 Levko loves array a1, a2, ... , an, consisting of i ...
- 套题 codeforces 360
A题:Opponents 直接模拟 #include <bits/stdc++.h> using namespace std; ]; int main() { int n,k; while ...
- codeforces 688D D. Remainders Game(中国剩余定理)
题目链接: D. Remainders Game time limit per test 1 second memory limit per test 256 megabytes input stan ...
- 【16.56%】【codeforces 687B】Remainders Game
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 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 ...
- codeforces 360 C
C - NP-Hard Problem Description Recently, Pari and Arya did some research about NP-Hard problems and ...
- codeforces 360 C - NP-Hard Problem
原题: Description Recently, Pari and Arya did some research about NP-Hard problems and they found the ...
- codeforces#687 B. Remainders Game
题意:给出n个数,和一个数p,问你在知道 x%ai 的情况下,能不能确定x%p的值 结论:当n个数的最小公倍数是p的倍数时,可以确定 代码: #include <bits/stdc++.h&g ...
- codeforces 360 B
B - Levko and Array 题目大意:给你你个长度为n的数列a,你最多改变k个值,max{ abs ( a[ i + 1] - a[ i ] ) } 的最小值为多少. 思路:这个题很难想到 ...
随机推荐
- java 深入技术八(内省)
1. javabean的软件设计思想 2.内省:封装了java反射,提供直接操作属性的Setter和getter方法的方法 3.核心API:BeanInfo java 的描述信息,Introspect ...
- C++小结
1.输入:cin>>变量名: 输出:cout<<变量名<<endl: 2.类 public 公有,此类及其他类中使用 private 私有,只能在本类中使用 ...
- [iOS] 为文本加上横线方法
_oldPriceLabel.text = "; _oldPriceLabel.textColor = [UIColor lightGrayColor]; NSMutableAttribut ...
- - > code vs 3038 3n+1问题(递归)
3038 3n+1问题 时间限制: 1 s 空间限制: 32000 KB 题目等级 : 白银 Silver 题解 题目描述 Description 3n+1问题是一个简单有趣而又没有解决的数 ...
- C# 类使用小demo
太晚了,不说了,直接上图 运行结果
- gulp整理
gulp基于node 1.全局安装gulp: $ npm install --global gulp 2.前往项目目录,然后安装作为项目的开发依赖(devDependencies): $ npm in ...
- java.io.Serializable 序列化接口
什么是序列化.反序列化? Serialization(序列化)是一种将对象以一连串的字节描述的过程: 反序列化deserialization是一种将这些字节重建成一个对象的过程. 序列化通俗一点说就是 ...
- spring加载过程,源码带你理解从初始化到bean注入
spring在容器启动时,容器正式初始化入口refresh()如下图 ①包括初始化FactoryBean.解析XML注册所有BeanDefinition信息 ②包括注册scope管理类 ③初始化单 ...
- LeetCode之263. Ugly Number
------------------------------------------------------------- 如果一个数的质因子只包括2,3,5,那么这个数n可以表示为:n=2x+3y+ ...
- Duilib源码分析(六)整体流程
在<Duilib源码分析(一)整体框架>.<Duilib源码分析(二)控件构造器—CDialogBuilder>以及<Duilib源码分析(三)XML解析器—CMarku ...