結果

問題 No.1083 余りの余り
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2020-06-19 21:45:58
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 735 bytes
コンパイル時間 1,286 ms
コンパイル使用メモリ 163,912 KB
実行使用メモリ 7,308 KB
最終ジャッジ日時 2024-07-03 14:13:18
合計ジャッジ時間 2,155 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.19 21:45:56
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    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());
    vector< int > dp(1 << n);
    dp[0] = k;
    int ans = 0;
    for (int i = 1; i < 1 << n; i++) {
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) {
                dp[i] = dp[i & (i - 1)] % a[n-1-j];
                break;
            }
        }
    }
    for (int i = 1; i < n; i++) {
        int p = 1 << i;
        ans = max(ans, dp[p - 1]);
    }
    cout << ans << endl;
    return 0;
}
0