結果

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

ソースコード

diff #

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++){
    	cin >> a[i];
    }
    int maki = 1 << n;
    vector<int> dp(maki, 0);
    dp[0] = k;
    for(int i=1;i<maki;i++){
    	for(int j=0;j<n;j++) if(i>>j & 1){
    		dp[i] = max(dp[i], dp[i-(1<<j)] % a[j]);
    	}
    }
    cout << dp[maki - 1] << endl;
    return 0;
}
0