Codeforces Round #360 (Div. 2) D. Remainders Game
1 second
256 megabytes
standard input
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.
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).
Print "Yes" (without quotes) if Arya has a winning strategy independent of value of x, or "No" (without quotes) otherwise.
4 5
2 3 5 12
Yes
2 7
2 3
No
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的更多相关文章
- Codeforces Round #360 (Div. 2) D. Remainders Game 数学
D. Remainders Game 题目连接: http://www.codeforces.com/contest/688/problem/D Description Today Pari and ...
- Codeforces Round #360 (Div. 2) D. Remainders Game 中国剩余定理
题目链接: 题目 D. Remainders Game time limit per test 1 second memory limit per test 256 megabytes 问题描述 To ...
- 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 ...
- Codeforces Round #360 (Div. 2) C. NP-Hard Problem 水题
C. NP-Hard Problem 题目连接: http://www.codeforces.com/contest/688/problem/C Description Recently, Pari ...
- Codeforces Round #360 (Div. 2) B. Lovely Palindromes 水题
B. Lovely Palindromes 题目连接: http://www.codeforces.com/contest/688/problem/B Description Pari has a f ...
- Codeforces Round #360 (Div. 2) A. Opponents 水题
A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...
- Codeforces Round #360 (Div. 1)A (二分图&dfs染色)
题目链接:http://codeforces.com/problemset/problem/687/A 题意:给出一个n个点m条边的图,分别将每条边连接的两个点放到两个集合中,输出两个集合中的点,若不 ...
- 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 ...
- 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, ...
随机推荐
- python爬虫系列(1)——一个简单的爬虫实例
本文主要实现一个简单的爬虫,目的是从一个百度贴吧页面下载图片. 1. 概述 本文主要实现一个简单的爬虫,目的是从一个百度贴吧页面下载图片.下载图片的步骤如下: 获取网页html文本内容:分析html中 ...
- spring 自定义事物同步器(一): TransactionSynchronizationManager 解析
一..JPA 获取 Hibernate的session try { session = entityManager.unwrap(Session.class); } catch (Exception ...
- 通过EditText的setTransformationMethod()隐藏或显示密码
private Button mBtnPassword; private EditText mEtPassword; private boolean mbDisplayFlg = false; /** ...
- centos删除乱码名称的文件
常规方法rm已经木有办法删除该文件了. 原理: 当文件名为乱码的时候,无法通过键盘输入文件名,所以在终端下就不能直接利用rm,mv等命令管理文件了.但是每个文件都有一个i节点号,可以通过i节点号来管理 ...
- java 多线程 day14 Semaphore 线程信号灯
import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;import java.util.c ...
- linux内核介绍
linux系统可以分为:包括用户空间和内核空间两个部分. 现代cpu通常实现了不同的工作模式,以ARM为例,实现了7种工作模式: 用户模式.快速中断.外部中断.管理模式.数据访问中止.系统模式.未定义 ...
- RAW nand clear NAND eMMC
raw NAND: raw NAND即是一般的NAND Flash内存芯片,所有的ECC除错机制(Error Correcting Code).区块管理(Block Management).磨损均衡技 ...
- XE6移动开发环境搭建之IOS篇(7):在Mac OSX 10.8中安装XE6的PAServer(有图有真相)
XE6移动开发环境搭建之IOS篇(7):在Mac OSX 10.8中安装XE6的PAServer(有图有真相) 2014-08-22 21:06 网上能找到的关于Delphi XE系列的移动开发环境的 ...
- Java基础知识陷阱(八)
本文发表于本人博客. 这次我来说说关于&跟&&的区别,大家都知道&是位运算符,而&&是逻辑运算符,看下面代码: public static void m ...
- Uvalive 7037 The Problem Needs 3D Arrays(最大密度子图)
题意:给一段子序列,定义密度:子序列中的逆序对数/子序列的长度 求这个序列的对大密度. 分析:将序列中的每个位置视作点,逆序对\(<i,j>\)之间表示点i与点j之间有一条无向边.所以就转 ...