結果

問題 No.1083 余りの余り
ユーザー llewkcor2178llewkcor2178
提出日時 2020-06-23 16:45:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 36 ms / 3,000 ms
コード長 1,372 bytes
コンパイル時間 1,528 ms
コンパイル使用メモリ 169,924 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 20:00:29
合計ジャッジ時間 3,032 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 9 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 19 ms
4,376 KB
testcase_19 AC 10 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 36 ms
4,380 KB
testcase_24 AC 35 ms
4,380 KB
testcase_25 AC 35 ms
4,380 KB
testcase_26 AC 35 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 34 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 35 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;
#define oorret true //std::out_of_rangeが返された時
#define oor(x) [&](){try{x;} catch(const std::out_of_range& oor){return oorret;} return x;}()
double pi = 3.141592653589793238;
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
ll M=1e9+7;
int quick_pow(int x,int p){
    int a=1,po=x;
    while(p){
        if(p&1)  a=1ll*a*po%M;
        po=1ll*po*po%M;p>>=1;
    }
    return a;
}
int nCr(int n, int r){
    r=min(r, n-r);
    ll a=1, b=1;
    rep(i, r){a*=n-i;a%=M;}
    rep2(i, r){b*=i;b%=M;}
    b=quick_pow(b, M-2);
    a*=b;a%=M;
    return a;
}
int Max=0;
void dfs(vector<int> A, int p, int k){
    if(p>0){
        rep(i, p){
            dfs(A, i, k%A[i]);
        }
    }else{
        Max=max(Max, k);
    }
}

int main(){
    int N, K;
    cin>>N>>K;
    vector<int> A(N);
    rep(i, N){
        cin>>A[i];
    }
    
    sort(A.begin(), A.end());
    dfs(A, N, K);
    cout<<Max<<endl;
}
0