結果
| 問題 |
No.1083 余りの余り
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-19 21:48:01 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 811 bytes |
| コンパイル時間 | 1,469 ms |
| コンパイル使用メモリ | 107,396 KB |
| 最終ジャッジ日時 | 2025-01-11 06:04:26 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 TLE * 6 MLE * 4 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <deque>
#include <cstdio>
#include <queue>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
set<int> dp[1<<20];
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n; cin >> n;
ll k; cin >> k;
vector<ll> a(n);
for(int i=0;i<n;i++){
cin >> a[i];
}
sort(a.begin(), a.end());
a.erase(unique(a.begin(), a.end()),a.end());
dp[0].insert(k);
for(int i=0;i<(1<<n);i++){
for(int j=0;j<n;j++){
if(i&(1<<j))continue;
for(auto s:dp[i]){
dp[i+(1<<j)].insert(s%a[j]);
}
}
}
cout << *dp[(1<<n)-1].rbegin() << endl;
}