結果
| 問題 |
No.1083 余りの余り
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-06 13:22:56 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,425 bytes |
| コンパイル時間 | 4,251 ms |
| コンパイル使用メモリ | 229,164 KB |
| 実行使用メモリ | 11,520 KB |
| 最終ジャッジ日時 | 2024-07-04 18:08:18 |
| 合計ジャッジ時間 | 6,535 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 WA * 4 |
ソースコード
#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() {
//#1 入力
int N, K;
cin >> N >> K;
vector<int> A(N);
cin >> A;
//#2 bitDP
vector<int> DP(1 << N, -1);
DP[0] = K;
for (int bit = 0; bit < (1ll << N) - 1; bit++) {
for (int i = 0; i < N; i++) {
if (bit & (1ll << i))continue;
chmax(DP[bit | (1ll << i)], DP[bit] % A[i]);
}
}
//#3 出力
cout << DP.back() << endl;
}
signed main() {
int T = 1;
// cin >> T;
for (int i = 0; i < T; i++)
solve();
return 0;
}