結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-05-03 06:10:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 730 bytes |
| コンパイル時間 | 793 ms |
| コンパイル使用メモリ | 68,540 KB |
| 実行使用メモリ | 10,272 KB |
| 最終ジャッジ日時 | 2024-09-14 05:11:06 |
| 合計ジャッジ時間 | 7,032 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 WA * 1 TLE * 1 -- * 7 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
int n;
int t;
std::vector<int> a(50, -1);
std::string s;
bool solve(int r, int i) {
if (r > t) {
return false;
}
if (i == n) {
if (r == t) {
return true;
} else {
return false;
}
}
if (solve(r + a[i], i + 1)) {
s.push_back('+');
return true;
} else if (solve(r * a[i], i + 1)) {
s.push_back('*');
return true;
} else {
return false;
}
}
int main() {
std::cin >> n >> t;
for (int i = 0; i < n; i++) {
std::cin >> a[i];
}
int r = a[0];
if(!solve(r, 1)) {
return 1;
}
std::cout << s << std::endl;
}