結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-10-04 22:54:19 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 719 bytes |
| コンパイル時間 | 1,434 ms |
| コンパイル使用メモリ | 160,092 KB |
| 実行使用メモリ | 22,656 KB |
| 最終ジャッジ日時 | 2024-11-16 18:52:54 |
| 合計ジャッジ時間 | 4,506 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 12 |
コンパイルメッセージ
main.cpp: In function ‘int recursive(int, int, int64_t)’:
main.cpp:19:16: warning: control reaches end of non-void function [-Wreturn-type]
19 | retval = recursive(pos + 1, val + A[pos], oper) ||
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 | recursive(pos + 1, val * A[pos], oper | (1 << pos));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
int N, T;
int A[50];
int dp[50][100000];
vector<int> zeros;
int64_t ans;
int recursive(int pos, int val, int64_t oper) {
int retval = 0;
if(pos >= N) {
if(val == T) {
ans = oper;
return 1;
}
return 0;
}
if(dp[pos][val]) return 0;
if(val > T) return 0;
retval = recursive(pos + 1, val + A[pos], oper) ||
recursive(pos + 1, val * A[pos], oper | (1 << pos));
}
int main() {
cin >> N >> T;
for(int i = 0; i < N; i++) {
cin >> A[i];
for(int j = 0; j < T; j++) {
dp[i][j] = 0;
}
if(A[i] == 0) zeros.push_back(i);
}
recursive(1, A[0], 0);
for(int i = 1; i < N; i++) {
cout << (ans & (1 << i) ? "*" : "+");
}
cout << endl;
return 0;
}