結果
| 問題 |
No.1083 余りの余り
|
| コンテスト | |
| ユーザー |
poohbear
|
| 提出日時 | 2020-06-19 21:56:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 814 bytes |
| コンパイル時間 | 2,085 ms |
| コンパイル使用メモリ | 195,528 KB |
| 最終ジャッジ日時 | 2025-01-11 06:10:49 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 WA * 3 RE * 6 |
ソースコード
#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[20][1100000];
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;
}
poohbear