結果

問題 No.1083 余りの余り
ユーザー poohbearpoohbear
提出日時 2020-06-19 21:59:38
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 815 bytes
コンパイル時間 3,450 ms
コンパイル使用メモリ 193,500 KB
最終ジャッジ日時 2025-01-11 06:14:50
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

ll n,k;
vector<ll>a;

ll dp[25][10000000];

int main(){
    cin >> n >> k;
    a.resize(n);
    rep(i,n)cin>>a[i];
    dp[0][0] = k;
    for(int bit=1;bit<(1<<n);bit++){
        int i = __builtin_popcount(bit);
        for(int j=0;j<n;j++){
            if((bit>>j)&1){
                chmax(dp[i][bit],dp[i-1][(1<<j)^bit]%a[j]);
            }
        }
    }
    cout << dp[n][(1<<n)-1] << endl;
    return 0;
}
0