結果

問題 No.1083 余りの余り
ユーザー 沙耶花沙耶花
提出日時 2020-06-19 21:28:06
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 107 ms / 3,000 ms
コード長 478 bytes
コンパイル時間 2,566 ms
コンパイル使用メモリ 198,464 KB
最終ジャッジ日時 2025-01-11 05:43:54
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000000



int main(){
	
	int N,K;
	cin>>N>>K;
	
	vector<int> A(N);
	for(int i=0;i<N;i++)cin>>A[i];
	
	sort(A.rbegin(),A.rend());
	int ans = 0;
	
	for(int i=0;i<(1<<N);i++){
		int t = K;
		for(int j=0;j<N-1;j++){
			if((i>>j)&1){
				t %= A[j];
			}
		}
		t %= A.back();
		ans = max(ans,t);
	}
	cout<<ans<<endl;
	
	return 0;
}
0