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 ] ) } 的最小值为多少. 思路:这个题很难想到 ...
随机推荐
- Python中操作mysql的pymysql模块详解
Python中操作mysql的pymysql模块详解 前言 pymsql是Python中操作MySQL的模块,其使用方法和MySQLdb几乎相同.但目前pymysql支持python3.x而后者不支持 ...
- Unity3D访问Android系统目录
file:///sdcard/Movies/3D/互动.mp4file:///storage/emulated/0/Movies/3D/互动.mp4/storage/emulated/0/Movies ...
- 出售Illustrator脚本插件面板(包含面板源码,以及面板上所有的功能源码)
出售Illustrator脚本插件面板(包含面板源码,以及面板上所有的功能源码) 购买后可提供相应的小修改,以及教你使用往这个多列面里再加上按钮功能! 这套源码可作为工作使用,也可用为新手学习AI脚面 ...
- windows耳机没有声音
问题描述: 扬声器有声音,耳机没有声音,重装了驱动也没有用,系统配置.耳机也没有问题,具体原因我不太清楚,参考网址:http://forum.ubuntu.org.cn/viewtopic.php?f ...
- dubbox rest服务
1.xml配置: web.xml 定义监听的contextpath,见rest协议定义 <servlet> <servlet-name>dispatcher</servl ...
- C# IEnumberable & IQueryable 区别
转自 http://blog.csdn.net/daimeisi123/article/details/46976093 在应用到IEnumberable 和IQueryable两个接口时,代码往往很 ...
- elasticsearch5.0.0 安装插件及配置过程
elasticsearch5.0.0 安装插件及配置过程 由于es5.0是里程碑式的更新,所以很多变化的地方,暂时我就插件安装遇到的问题记录一下. 插件安装命令 2.3版本的安装命令 安装Marvel ...
- 【Java EE 学习 79 下】【动态SQL】【mybatis和spring的整合】
一.动态SQL 什么是动态SQL,就是在不同的条件下,sql语句不相同的意思,曾经在“酒店会员管理系统”中写过大量的多条件查询,那是在SSH的环境中,所以只能在代码中进行判断,以下是其中一个多条件查询 ...
- "Fatal error: Call to undefined function: file_put_contents()"
打开页面时提示这个错误: Fatal error: Call to undefined function: file_put_contents() 意思是请求未定义的函数,出现这个提示通常有两种情况: ...
- F#之旅1 - Why use F#?为什么要用F#?
原文地址:http://fsharpforfunandprofit.com/why-use-fsharp/ Why use F#?Why you should consider using F# fo ...