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 ] ) } 的最小值为多少. 思路:这个题很难想到 ...
随机推荐
- rocketmq生产者部署的机器注意事项
报错: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'warningP ...
- sh 测试网段在线主机
yum install nmap nmap -sP 192.168.21.1/24 查看网段在线主机 grep -vwf file1 file2 文件内容比较 #!/bin/bash # day=` ...
- Java数据类型和MySql数据类型对应表
- sql 查询当前数据库所有表格以及所有表格数据条数
select b.name as tablename , a.rowcnt as datacount from sysindexes a , sysobjects b where a.id = b.i ...
- 编译器--__attribute__ ((packed))
1. __attribute__ ((packed)) 的作用就是告诉编译器取消结构在编译过程中的优化对齐,按照实际占用字节数进行对齐,是GCC特有的语法.这个功能是跟操作系统没关系,跟编译器有关,g ...
- retrofit使用随记
1.请求接口 public interface RetrofitApi { /*注册*/ /*登录*/ @FormUrlEncoded //post请求带这个 @POST("url" ...
- iOS打包测试
iOS开发中,怎么打包为ipa格式的软件包以及怎么安装到手机终端上. (我的开发环境为Xcode6.1.1 )作为个人开发者(当然我的开发者帐号为个人开发者帐号,而不是企业开发者帐号),对于自己来说, ...
- 让tomcat启动更快的设置
http://wiki.apache.org/tomcat/HowTo/FasterStartUp#Entropy_Source 关于随机数的"熵源"(entropy source ...
- 分享一个分布式消息总线,基于.NET Socket Tcp的发布-订阅框架,附代码下载
一.分布式消息总线 在很多MIS项目之中都有这样的需求,需要一个及时.高效的的通知机制,即比如当使用者A完成了任务X,就需要立即告知使用者B任务X已经完成,在通常的情况下,开发人中都是在使用者B所使用 ...
- 当年只会C# 所以写C++就成这样了! log4cplus -> log4net
属实C++不会. 目前帮朋友弄个小项目需要小折腾一下. c# 一直采用 log4net ,c++的呢,找找有个log4cplus 知识有限,做个通用类吧.别把精力放在这里. 动手创建个静态类. 为了 ...