• HDU 1788: Chinese remainder theorem again


    2 1

    2 3

    0 0

    5

    分析:表面中国剩余定理。。。

    #include <iostream>
    #include <string>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #define range(i,a,b) for(int i=a;i<=b;++i)
    #define rerange(i,a,b) for(int i=a;i>=b;--i)
    #define LL long long
    #define CLS(arr) memset(arr,0,sizeof(arr))
    using namespace std;
    LL l,n;
    LL gcd(LL a,LL b){
        return !b?a:gcd(b,a%b);
    }
    void solve(){
        while(cin>>l>>n,l,n){
            LL lcm=1,num;
            range(i,1,l){
                cin>>num;
                lcm=lcm*num/gcd(lcm,num);
            }
            cout<<lcm-n<<endl;
        }
    }
    int main(int argc, char *argv[]){
        solve();
        return 0;
    }
    View Code
  • 相关阅读:
    线程池和进程池
    初识数据库
    线程q
    event事件
    死锁和递归锁
    信号量
    PythonStudy——线程中的几种消息队列
    PythonStudy——GIL Global Interpreter Lock 全局解释器锁
    PythonStudy——异步回调
    PythonStudy——日志模块 logging
  • 原文地址:https://www.cnblogs.com/Rhythm-/p/9322648.html
Copyright © 2020-2023  润新知