結果

問題 No.1083 余りの余り
ユーザー merom686merom686
提出日時 2020-06-19 22:58:32
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 57 ms / 3,000 ms
コード長 670 bytes
コンパイル時間 965 ms
コンパイル使用メモリ 96,912 KB
最終ジャッジ日時 2025-01-11 07:41:21
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());

    int r = 0;
    for (int x = 0; x < 1 << (n - 1); x++) {
        int t = k;
        for (int i = 0; i < n - 1; i++) {
            if (x >> i & 1) {
                t %= a[i];
            }
        }
        r = max(r, t % a.back());
    }

    cout << r << endl;

    return 0;
}
0