結果
| 問題 |
No.1083 余りの余り
|
| コンテスト | |
| ユーザー |
poohbear
|
| 提出日時 | 2020-06-19 22:04:09 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 812 bytes |
| コンパイル時間 | 2,437 ms |
| コンパイル使用メモリ | 193,476 KB |
| 最終ジャッジ日時 | 2025-01-11 06:23:25 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 WA * 4 |
ソースコード
#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(ll bit=1;bit<(1<<n);bit++){
ll i = __builtin_popcount(bit);
for(ll 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