zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    计算数组的逆序对个数
    处理类型(typedef,uisng,auto,decltype)
    constexpr与常量表达式(c++11标准)
    const的限定
    void*类型的指针
    linux终端拖动鼠标总是产生ctrl+c
    Linux hrtimer分析(2)
    Linux hrtimer分析(一)
    Alarm(硬件时钟) init
    第十一章 Android 内核驱动——Alarm
  • 原文地址:https://www.cnblogs.com/Rhythm-/p/9322648.html
Copyright © 2011-2022 走看看