結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-04-22 04:49:08 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 526 bytes |
| コンパイル時間 | 1,260 ms |
| コンパイル使用メモリ | 157,780 KB |
| 実行使用メモリ | 10,016 KB |
| 最終ジャッジ日時 | 2024-07-05 00:04:56 |
| 合計ジャッジ時間 | 7,763 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 TLE * 1 -- * 7 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
typedef long long Int;
#define REP(i,n) for(int (i)=0;(i)<(int)(n);++(i))
int N;
int total;
int A[55];
char ops[55];
void dfs(int d, int val) {
if (d == N) {
if (val == total) {
throw 1;
}
return;
}
if (val > total) return;
ops[d] = '+';
dfs(d + 1, val + A[d]);
ops[d] = '*';
dfs(d + 1, val * A[d]);
}
int main() {
cin >> N >> total;
REP(i, N) cin >> A[i];
try { dfs(1, A[0]); } catch (int e) {}
for (int i = 1; i < N; i++) cout << ops[i]; cout << endl;
}