結果
問題 | No.1083 余りの余り |
ユーザー |
|
提出日時 | 2023-03-08 18:20:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 83 ms / 3,000 ms |
コード長 | 1,394 bytes |
コンパイル時間 | 1,486 ms |
コンパイル使用メモリ | 173,800 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-18 02:37:02 |
合計ジャッジ時間 | 3,180 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;template <typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;using pii = pair<int, int>;using pll = pair<ll, ll>;using Graph = vector<vector<int>>;const ll INF = 1LL << 60;template <class T>void chmax(T& a, T b) {if (b > a) a = b;}template <class T>void chmin(T& a, T b) {if (b < a) a = b;}template <typename T, typename S>std::ostream& operator<<(std::ostream& os, const pair<T, S>& x) noexcept {return os << "(" << x.first << ", " << x.second << ")";}template <typename T>void print_vector(vector<T> a) {cout << '[';for (int i = 0; i < a.size(); i++) {cout << a[i];if (i != a.size() - 1) {cout << ", ";}}cout << ']' << endl;}int main() {ios::sync_with_stdio(false);std::cin.tie(nullptr);ll N, K;cin >> N >> K;vector<ll> A(N);for (int i = 0; i < N; i++) {cin >> A[i];}ll M = 1 << N;sort(A.begin(), A.end());reverse(A.begin(), A.end());ll ret = 0;for (int bit = 0; bit < (1 << (N - 1)); ++bit) {std::vector<int> S;ll X = K;for (int i = 0; i < N; ++i) {if (bit & (1 << i)) X %= A[i];}X %= A[N - 1];chmax(ret, X);}std::cout << ret << "\n";return 0;}