結果
| 問題 | No.1083 余りの余り |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-04-04 13:37:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 3,000 ms |
| コード長 | 652 bytes |
| 記録 | |
| コンパイル時間 | 889 ms |
| コンパイル使用メモリ | 84,156 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-01 06:30:16 |
| 合計ジャッジ時間 | 2,051 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<ctime>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
typedef long long LL;
const int MR=100;
int n,K,ans;
int a[MR];
void dfs(int p,int r){//决定a[p]要不要模
if(r<ans) return;
if(p==n){
ans=max(ans,r%a[n]);//第n个是最小的a,必须模
return;
}
dfs(p+1,r);
dfs(p+1,r%a[p]);
}
int main(){
cin>>n>>K;
for(int i=1;i<=n;i++){
cin>>a[i];
}
sort(a+1,a+1+n);
reverse(a+1,a+1+n);
dfs(1,K);
cout<<ans<<endl;
return 0;
}