結果

問題 No.1083 余りの余り
ユーザー warabi0906warabi0906
提出日時 2023-02-06 13:32:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 101 ms / 3,000 ms
コード長 1,406 bytes
コンパイル時間 5,663 ms
コンパイル使用メモリ 229,132 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-18 01:12:37
合計ジャッジ時間 8,023 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 24 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 48 ms
4,380 KB
testcase_19 AC 24 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 4 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 100 ms
4,376 KB
testcase_24 AC 101 ms
4,376 KB
testcase_25 AC 100 ms
4,380 KB
testcase_26 AC 100 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 100 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 99 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include "atcoder/all"
#define debug cout << "OK" << endl;
template<typename T>
inline bool chmax(T& a, const T b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
inline bool chmin(T& a, const T b) { if (a > b) { a = b; return true; } return false; }
inline int Code(char c) {
	if ('A' <= c and c <= 'Z')return (int)(c - 'A');
	if ('a' <= c and c <= 'z')return (int)(c - 'a');
	if ('0' <= c and c <= '9')return (int)(c - '0');
	assert(false);
}
using namespace std;
using namespace atcoder;
#define int long long
constexpr int MOD = 998244353;
constexpr int INF = (1LL << 62);
using minit = modint998244353;

template<typename T>
ostream& operator << (ostream& st, const vector<T> &v) {
	for (const T value : v) {
		st << value << " ";
	}
	return st;
}
template<typename T>
istream& operator >> (istream& st, vector<T>& v) {
	for (T &value : v) {
		st >> value;
	}
	return st;
}

//
typedef struct {
	int to, cost;
}edge;
//

void solve() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	cin >> A;

	int ans = 0;
	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());
	for (int bit = 0; bit < (1ll << (N - 1)); bit++) {
		int k = K;
		for (int i = 0; i < N - 1; i++)if (bit & (1ll << i))k %= A[i];
		k %= A.back();
		chmax(ans, k);
	}
	cout << ans << endl;
}
signed main() {
	int T = 1;
	// cin >> T;
	for (int i = 0; i < T; i++)
		solve();
	return 0;
}
0