博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CodeForces 687B Remainders Game
阅读量:7002 次
发布时间:2019-06-27

本文共 1509 字,大约阅读时间需要 5 分钟。

数论。

如果$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
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;typedef long long LL;const double pi=acos(-1.0),eps=1e-6;void File(){ freopen("D:\\in.txt","r",stdin); freopen("D:\\out.txt","w",stdout);}template
inline void read(T &x){ char c = getchar(); x = 0;while(!isdigit(c)) c = getchar(); while(isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); }}LL gcd(LL a,LL b){ if(b==0) return a; return gcd(b,a%b);}LL lcm(LL a,LL b){ return a*b/gcd(a,b);}int n;LL ans=1,k;int main(){ scanf("%d%lld",&n,&k); for(int i=1;i<=n;i++) { LL x; scanf("%lld",&x); ans=lcm(ans,x)%k; } if(ans) printf("No\n"); else printf("Yes\n"); return 0;}

 

转载于:https://www.cnblogs.com/zufezzt/p/5840260.html

你可能感兴趣的文章
java SSM 框架 微信自定义菜单 快递接口 SpringMVC mybatis redis shiro ehcache websocket
查看>>
[Unity] Shader(着色器)输入输出和语义
查看>>
Flutter学习之Dart语言基础(构造函数)
查看>>
条形码设计软件BarTender实用教程——模板对象常见问题解答
查看>>
Mongo Connector for BI
查看>>
关于mysql里的concat
查看>>
wcf基础(笔记)
查看>>
设置Eclipse中的tab键为4个空格的完整方法
查看>>
玩坏的Bad Apple之Vim
查看>>
常见的移动端H5页面开发遇到的坑和解决办法
查看>>
Xshell 主机和远程机之间的文件传输
查看>>
微信支付宝扫码支付相关接口
查看>>
菜鸟级asp.net 与ms sql server数据库打交道的简单总结
查看>>
机器学习中的度量——统计上的距离
查看>>
15.事件
查看>>
99.ext afteredit事件详解
查看>>
CSMA/CD
查看>>
Logistic回归
查看>>
jq ajax之beforesend(XHR)
查看>>
P2151 [SDOI2009]HH去散步
查看>>