結果

問題 No.1083 余りの余り
ユーザー 66
提出日時 2024-01-30 05:42:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 126 ms / 3,000 ms
コード長 1,871 bytes
コンパイル時間 2,397 ms
コンパイル使用メモリ 207,584 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-30 05:42:45
合計ジャッジ時間 4,871 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll linf=(1LL<<60) - 1;
const int inf=(1LL<<30) - 1;
const int mod=1000000007;
const int MOD=998244353;
const ll dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const ll dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
#define overload4(a,b,c,d,name,...) name
#define rep1(n) for(long long _=0;_<n;++_)
#define rep2(i,n) for(long long i=0;i<n;++i)
#define rep3(i,a,b) for(long long i=a;i<b;++i)
#define rep4(i,a,b,c) for(long long i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define rrep1(n) for(ll _=n;_--;)
#define rrep2(i,n) for(ll i=n;i--;)
#define rrep3(i,a,b) for(ll i=b;i-->(a);)
#define rrep4(i,a,b,c) for(ll i=(a)+((b)-(a)-1)/(c)*(c);i>=(a);i-=c)
#define rrep(...) overload4(__VA_ARGS__,rrep4,rrep3,rrep2,rrep1)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend() 
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define vv(type,name,h,...) vector name(h,vector<type>(__VA_ARGS__))
#define vvv(type,name,h,w,...) vector name(h,vector(w,vector<type>(__VA_ARGS__)))
#define vvvv(type, name, h, w, n, ...) vector<vector<vector<vector<type>>>> name(h, vector<vector<vector<type>>>(w, vector<vector<type>>(n, vector<type>(__VA_ARGS__))))
struct Setting{ Setting(){ cin.tie(nullptr)->sync_with_stdio(0); fixed(cout).precision(12); } }Setting;
// #define _GLIBCXX_DEBUG
//-----------------------------------


void solve() {
    int N, K; cin >> N >> K;
    vector<int> A(N); rep(i, N) cin >> A[i];
    sort(rall(A));
    ll ans = 0;
    rep(bit, 1<<(N-1)) {
        ll t = K;
        rep(i, N-1) {
            if(bit&(1<<i)) t %= A[i];
        }
        t %= A.back();
        ans = max(ans, t);
    }
    cout << ans << endl;
}



int main() { 
    int T = 1;
    //// cin >> T;
    while(T--) {
        solve();
    }
}
    
0