結果
問題 |
No.1083 余りの余り
|
ユーザー |
![]() |
提出日時 | 2020-12-20 20:28:32 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 3,000 ms |
コード長 | 736 bytes |
コンパイル時間 | 4,152 ms |
コンパイル使用メモリ | 142,716 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-21 12:10:34 |
合計ジャッジ時間 | 5,608 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
#include <cassert> #include <cmath> #include <algorithm> #include <iostream> #include <iomanip> #include <limits.h> #include <map> #include <queue> #include <set> #include <string.h> #include <vector> using namespace std; typedef long long ll; const int MAX_N = 20; int main() { int N, K; cin >> N >> K; vector<int> A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } sort(A.begin(), A.end()); reverse(A.begin(), A.end()); int ans = 0; for (int mask = 0; mask < (1 << N); ++mask) { if ((mask >> (N - 1) & 1) == 0) continue; int V = K; for (int i = 0; i < N; ++i) { if ((mask >> i & 1) == 0) continue; V %= A[i]; } ans = max(ans, V); } cout << ans << endl; return 0; }