結果
| 問題 |
No.1083 余りの余り
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-19 21:34:37 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,148 bytes |
| コンパイル時間 | 1,531 ms |
| コンパイル使用メモリ | 173,672 KB |
| 実行使用メモリ | 11,528 KB |
| 最終ジャッジ日時 | 2024-07-03 14:01:25 |
| 合計ジャッジ時間 | 5,873 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 WA * 4 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;
struct Debug {
template<class T> static void print_value(T value,const char* name) {
cout << name << ": " << value << '\n';
}
template<class T> static void print_vector(vector<T> &vec,const char* name) {
for (int i = 0;i < vec.size();++i) {
cout << " " << name;
printf("[%d]: ",i);
cout << vec[i];
}
cout << '\n';
}
template<class T> static void print_2dvector(vector<vector<T>> &vec,const char* name) {
for (int i = 0;i < vec.size();++i) {
for (int j = 0;j < vec[i].size();++j) {
cout << " " << name;
printf("[%d][%d]: ",i,j);
cout << vec[i][j];
}
cout << '\n';
}
}
template<class T> static void print_set(set<T> &st,const char* name) {
int i = 0;
for (auto itr = st.begin();itr != st.end(); ++itr,++i) {
cout << " " << name;
printf("[%d]: ",i);
cout << *itr;
}
cout << '\n';
}
template<class T1,class T2>
static void print_map(map<T1,T2> &mp,const char* name) {
for (auto p: mp) {
cout << " " << name << '[' << p.first << ']' << ": " << p.second;
}
cout << '\n';
}
};
int main() {
ll N,K; cin >> N >> K;
vector<ll> A(N);
rep(i,N) cin >> A[i];
vector<ll> dp(1<<N,0);
dp[0] = K;
rep(bit,1<<N) {
vector<int> stand;
vector<int> sit;
rep(i,N) {
if ((bit>>i)&1) stand.push_back(i);
else sit.push_back(i);
}
for (int i:sit) {
dp[bit^(1<<i)] = max(dp[bit^(1<<i)],dp[bit]%A[i]);
}
}
//Debug::print_vector(dp,"dp");
cout << dp[(1<<N) - 1] << endl;
return 0;
}