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-6;
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 = 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值