結果
問題 | No.1083 余りの余り |
ユーザー |
![]() |
提出日時 | 2020-06-20 13:04:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 249 ms / 3,000 ms |
コード長 | 793 bytes |
コンパイル時間 | 2,805 ms |
コンパイル使用メモリ | 199,352 KB |
最終ジャッジ日時 | 2025-01-11 08:36:40 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h>#define rep(a,n) for (ll a = 0; a < (n); ++a)using namespace std;typedef long long ll;typedef pair<ll,ll> P;typedef pair<ll,P> PP;typedef vector<vector<ll> > Graph;template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }const ll INF = 1e18;ll n,k;vector<ll>a;int main(){cin >> n >> k;a.resize(n);rep(i,n)cin>>a[i];sort(a.rbegin(),a.rend());ll ans = 0;for(int bit=1;bit<(1<<n);bit++){ll now = k;rep(i,n){if((bit>>i)&1){now %= a[i];}}now %= a[n-1];chmax(ans,now);}cout << ans << endl;return 0;}