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, ...
随机推荐
- boost 使用列子
#include <boost/lexical_cast.hpp>void test_lexical_cast(){ int number = 123; string str = &quo ...
- 003-maven简介
1.1简介 Maven,只是的积累,专家或内行 Maven是优秀的构建工具,依赖管理工具,项目信息管理工具,跨平台.提供了中央仓库,自动下载构件. 1.通过坐标系统定位每一个构件(artifact), ...
- go-009-函数
一.概述 Go 语言最少有个 main() 函数. 你可以通过函数来划分不同功能,逻辑上每个函数执行的是指定的任务. 函数声明告诉了编译器函数的名称,返回类型,和参数. Go 语言标准库提供了多种可动 ...
- 脚本其实很简单-windows配置核查程序(2)
bat脚本是什么? 首先讲讲什么是命令行,在windows操作系统中,点击左下角的win图标,直接输入cmd搜索,左键点击进入命令行模式(或按键盘上的win键+r直接调出来命令行窗口). 在windo ...
- vim使用winmanager整合nerd tree和taglist
winmanager插件安装 • 插件简介 winmanager is a plugin which implements a classical windows type IDE in Vim-6. ...
- postgresql 建模文件 LDM 转成PDM 生成 SQL问题
LDM 转成 PDM (Tool --- GPDM ) 生成 SQL,查看全部SQL 详细步骤见下图. 1.postgresql 没有 VARCHAR2 只有 VARCHAR. 2.LDM 生成 PD ...
- Android 环境搭建资料及启动过程中问题汇总
一.环境搭建资料 推荐谷歌自己开发的Android Studio 工具可以从这个网址下载:http://tools.android-studio.org/,直接下载推荐的就行 二.安装 安装时最好指定 ...
- kubernetes elasticsearch2.4 集群安装
一.制作docker镜像: Dockerfile文件: FROM alpine:latest MAINTAINER chengcuichao RUN apk update && apk ...
- 2017浙江省赛 C - What Kind of Friends Are You? ZOJ - 3960
地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3960 题目: Japari Park is a large zoo ...
- WebMagic 爬虫框架
官方网站[http://webmagic.io/](http://webmagic.io/) >webmagic是一个开源的Java垂直爬虫框架,目标是简化爬虫的开发流程,让开发者专注于逻辑功能 ...