結果
問題 |
No.10 +か×か
|
ユーザー |
|
提出日時 | 2015-02-05 03:06:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 615 bytes |
コンパイル時間 | 365 ms |
コンパイル使用メモリ | 55,516 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-06-23 07:54:07 |
合計ジャッジ時間 | 6,870 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 TLE * 1 -- * 7 |
ソースコード
//No.10 +か×か #include <iostream> #include <bitset> #define N_MAX 50 typedef unsigned long long LL; using namespace std; int N, T, A[N_MAX]; LL cal(int t, int i) { if (t == T && i >= N) return 0; if (t > T || i >= N) return -1; LL ans = cal(t + A[i], i + 1); if (ans != -1) return ans; ans = cal(t * A[i], i + 1); if (ans != -1) return ans | ((LL)1 << i); return -1; } int main() { const char* op = "+*"; cin >> N >> T; for (int i = 0; i < N; ++i) cin >> A[i]; //計算 bitset<64> ans(cal(A[0], 1)); for (int i = 1; i < N; ++i) cout << op[ans[i]]; cout << endl; return 0; }