結果
問題 | No.1083 余りの余り |
ユーザー |
![]() |
提出日時 | 2020-06-24 02:25:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 73 ms / 3,000 ms |
コード長 | 979 bytes |
コンパイル時間 | 2,840 ms |
コンパイル使用メモリ | 198,436 KB |
最終ジャッジ日時 | 2025-01-11 09:47:57 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;using ld = long double;#define rep(i, N) for (int i = 0; i < (int)(N); ++i)#define rrep(i, N) for (int i = (int)(N)-1; i >= 0; --i)#define debug(x) cout << #x << "=" << x << endl;constexpr int MOD=1000000007;constexpr ll INF = (1LL << 61) - 1;template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;} return false;}template <typename T> void fail(T v){cout << v << endl;exit(0);}//templtevoid solve(){int N,K;cin>>N>>K;vector<int> A(N);rep(i,N)cin>>A[i];sort(A.rbegin(),A.rend());int mx=0;rep(i,1<<(N-1)){int now=K;rep(j,N)if(1&i>>j)now%=A[j];chmax(mx,now%A.back());}cout<<mx<<endl;}int main(){cin.tie(0);ios::sync_with_stdio(false);//cout << fixed << setprecision(20);solve();return 0;}