CodeForces 687B Remainders Game
数论。
如果$x$不唯一,假设存在两个解,较大的为${x_1}$,较小的为${x_2}$。
那么,
$\left\{ {\begin{array}{*{20}{c}}
{{x_1}\% {c_i} = {x_2}\% {c_i}}\\
{{x_1}\% k \ne {x_2}\% k}
\end{array}} \right. \Rightarrow \left\{ {\begin{array}{*{20}{c}}
{({x_1} - {x_2})\% {c_i} = 0}\\
{({x_1} - {x_2})\% k \ne 0}
\end{array}} \right.$。
$∵lcm({c_1},{c_2},{c_3},......,{c_n})\% {c_i} = 0$
$∴lcm({c_1},{c_2},{c_3},......,{c_n})\% ({x_1} - {x_2}) = 0$
$∵({x_1} - {x_2})\% k \ne 0$
$∴lcm({c_1},{c_2},{c_3},......,{c_n})\% k \ne 0$
也就是说:如果解不唯一,那么$lcm({c_1},{c_2},{c_3},......,{c_n})\% k \ne 0$。
换句话说就是:如果解唯一,那么$lcm({c_1},{c_2},{c_3},......,{c_n})\% k = 0$。
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-;
void File()
{
freopen("D:\\in.txt","r",stdin);
freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
char c = getchar(); x = ;while(!isdigit(c)) c = getchar();
while(isdigit(c)) { x = x * + c - ''; c = getchar(); }
} LL gcd(LL a,LL b)
{
if(b==) return a;
return gcd(b,a%b);
} LL lcm(LL a,LL b)
{
return a*b/gcd(a,b);
} int n;
LL ans=,k; int main()
{
scanf("%d%lld",&n,&k);
for(int i=;i<=n;i++)
{
LL x; scanf("%lld",&x);
ans=lcm(ans,x)%k;
}
if(ans) printf("No\n");
else printf("Yes\n"); return ;
}
CodeForces 687B Remainders Game的更多相关文章
- Codeforces 687B. Remainders Game[剩余]
B. Remainders Game time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- codeforces 687B - Remainders Game 数学相关(互质中国剩余定理)
题意:给你x%ci=bi(x未知),是否能确定x%k的值(k已知) ——数学相关知识: 首先:我们知道一些事情,对于k,假设有ci%k==0,那么一定能确定x%k的值,比如k=5和ci=20,知道x% ...
- CodeForces 687B Remainders Game(数学,最小公倍数)
题意:给定 n 个数,一个数 k,然后你知道一个数 x 取模这个 n 个的是几,最后问你取模 k,是几. 析:首先题意就看了好久,其实并不难,我们只要能从 n 个数的最小公倍数是 k的倍数即可,想想为 ...
- 【16.56%】【codeforces 687B】Remainders Game
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Codeforces Educational Codeforces Round 5 E. Sum of Remainders 数学
E. Sum of Remainders 题目连接: http://www.codeforces.com/contest/616/problem/E Description The only line ...
- Codeforces Round #360 (Div. 2) D. Remainders Game 数学
D. Remainders Game 题目连接: http://www.codeforces.com/contest/688/problem/D Description Today Pari and ...
- codeforces 360 D - Remainders Game
D - Remainders Game Description Today Pari and Arya are playing a game called Remainders. Pari choos ...
- codeforces 616E Sum of Remainders (数论,找规律)
E. Sum of Remainders time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- Educational Codeforces Round 5 E. Sum of Remainders (思维题)
题目链接:http://codeforces.com/problemset/problem/616/E 题意很简单就不说了. 因为n % x = n - n / x * x 所以答案就等于 n * m ...
随机推荐
- dapper 扩展插件: Rainbow
dapper 扩展插件: Rainbow dapper 是一个效率非常高的orm 框架 ,效率要远远大于 我们大微软的EF . 它只有一个类文件,非常之小. 1,首先下载dapper 这里下 ...
- ODP.NET Managed正式推出
NET Oracle Developer的福音——ODP.NET Managed正式推出 在.NET平台下开发Oracle应用的小伙伴们肯定都知道一方面做Oracle开发和实施相比SqlServer要 ...
- asp.net的ajax以及json
asp.net的ajax以及json 来现在这家公司以前,从未接触过webform,以前在学校做的项目是php,java以及asp.net mvc的,当时asp.net mvc用的是razor引擎,所 ...
- myeclipse 配置 resin-pro-4.0.34
热部署: 在 resin.xml 文件下 增加 <host id="" root-directory="."> <!-- webapps ca ...
- 使用 App Studio 快速定制一个你自己的专属应用
使用 App Studio 快速定制一个你自己的专属应用 如果已有做一个手机应用的想法,只需要一些简单的图片,视频,或者RSS源,就可以通过App Studio制作出你心仪的应用! App Studi ...
- Linux系统小问题解决总结
[解决Ubuntu missing launcher and menu bar的问题] 按下ctrl + Alt + T打开终端: 输入以下命令: dconf reset -f /org/compiz ...
- asp.net mvc4设置area里面使用相同的 Controller 名称并设置area里的页面为起始页
asp.net mvc4设置area里面使用相同的 Controller 名称并设置area里的页面为起始页 1.使用重名controller 在asp.net mvc2以后的版本里面,有了area( ...
- SVN Access to '/svn/Test/!svn/me' forbidden,不能更新解决办法
从之前的电脑将Repositorise复制到现在用的PC,出现可以checkout但是不能update的问题.在网上找到以下解决方法,均未能解决. 1.确认URL跟实际一致: 2.确认用户名密码正确: ...
- 《Head First Python》学习笔记03 异常处理
异常(运行时错误): 当代码逻辑遇到意外事件时,比如打开一个文件,却发现文件不存在.这时是增加额外的代码处理逻辑,还是捕获异常呢?答案是:Python优先推荐捕获异常,然后恢复. Python异常机制 ...
- TaintDroid:智能手机监控实时隐私信息流跟踪系统(三)
4.3 原生代码标记传播 Native 代码是不受TaintDroid监控的.理想情况下,我们获得了相同的传播语义当使用相同的解释副本时.因此,为了精确的在Java层进行污点监控,我们定义了两个必 ...