結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
moti
|
| 提出日時 | 2015-07-25 00:24:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 831 bytes |
| コンパイル時間 | 894 ms |
| コンパイル使用メモリ | 85,848 KB |
| 実行使用メモリ | 231,092 KB |
| 最終ジャッジ日時 | 2024-07-16 03:18:53 |
| 合計ジャッジ時間 | 8,779 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 3 RE * 5 |
ソースコード
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
int N, tot;
vector<int> A;
std::string dp[101000][55];
std::string dfs(int now, int idx) {
auto& ret = dp[now][idx];
if(!ret.empty()) { return ret; }
ret = "1"; rep(i, 55) ret += "1";
if(idx == N) {
if(tot != now) { return ret; }
return ret = "";
}
return ret = min(dfs(now+A[idx], idx+1) + "0", dfs(now*A[idx], idx+1) + "1");
}
int main() {
cin >> N >> tot;
rep(i, N) {
int a; cin >> a;
A.push_back(a);
}
auto ans = dfs(A[0], 1);
rep(i, ans.size()) {
cout << (ans[i] == '0' ? '+' : '*');
}
cout << endl;
return 0;
}
moti