結果
| 問題 |
No.1083 余りの余り
|
| コンテスト | |
| ユーザー |
le_panda_noir
|
| 提出日時 | 2020-06-20 20:50:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 765 bytes |
| コンパイル時間 | 985 ms |
| コンパイル使用メモリ | 78,340 KB |
| 最終ジャッジ日時 | 2025-01-11 08:47:02 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 WA * 1 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
int main() {
int N, K;
ins(N, K);
vector<int> A(N);
rep(i, N) {
cin >> A[i];
}
all(sort, A);
all(reverse, A);
int ans = 0;
if (N == 1) {
cout << K % A[0] << endl;
return 0;
}
rep(bit, 1<<(N-1)) {
int x = K;
if (bit == 0)
continue;
rep(i, N) {
if (bit & (1 << i)) {
x %= A[i];
}
}
ans = max(ans, x % A.back());
}
cout << ans << endl;
return 0;
}
le_panda_noir