結果
問題 | No.1083 余りの余り |
ユーザー |
👑 |
提出日時 | 2020-01-28 22:30:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 99 ms / 3,000 ms |
コード長 | 649 bytes |
コンパイル時間 | 865 ms |
コンパイル使用メモリ | 77,936 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-02 23:39:16 |
合計ジャッジ時間 | 2,673 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
#include <iostream> #include <algorithm> #include <vector> #include <cassert> #include <set> using namespace std; vector<int> A; int n,k; int ans; int main(){ cin>>n>>k; assert(20 >= n); assert(n >= 1); assert(1000000000 >= k); assert(k >= 1); for(int i = 0; n > i; i++){ int T;cin>>T; assert(1000000000 >= T); assert(T >= 1); A.push_back(T); } sort(A.begin(),A.end(),greater<int>()); int ans = 0; for(int bit = 0; (1 << n) > bit; bit++){ int nw = k; for(int i = 0; n > i; i++){ if(bit & (1<<i)){ nw%=A[i]; } } ans = max(ans,nw%A[A.size()-1]); } cout << ans << endl; }