zoukankan      html  css  js  c++  java
  • CodeForces 687B Remainders Game

    数论。

    如果$x$不唯一,假设存在两个解,较大的为${x_1}$,较小的为${x_2}$。

    那么,

    $left{ {egin{array}{*{20}{c}}
    {{x_1}\% {c_i} = {x_2}\% {c_i}}\
    {{x_1}\% k e {x_2}\% k}
    end{array}} ight. Rightarrow left{ {egin{array}{*{20}{c}}
    {({x_1} - {x_2})\% {c_i} = 0}\
    {({x_1} - {x_2})\% k e 0}
    end{array}} ight.$。

    $∵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 e 0$

    $∴lcm({c_1},{c_2},{c_3},......,{c_n})\% k e 0$

    也就是说:如果解不唯一,那么$lcm({c_1},{c_2},{c_3},......,{c_n})\% k e 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
    ");
        else printf("Yes
    ");
    
        return 0;
    }
  • 相关阅读:
    【Python】使用codecs模块进行文件操作及消除文件中的BOM
    Vue公共结果页面实现
    vscode调整字体大小
    vue-cli3使用vue-svg-loader加载svg
    Microsoft Edge Chrome 下载
    [译]基于Vue.js的10个最佳UI框架,用于构建移动应用程序
    axios采坑之路
    MacBook Touch Bar 使用技巧
    vue-cli 3.x 移除console总结
    嵌入式Linux如何设置获取uboot参数
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5840260.html
Copyright © 2011-2022 走看看