結果
| 問題 |
No.10 +か×か
|
| ユーザー |
A63635985
|
| 提出日時 | 2018-03-03 23:10:44 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 921 bytes |
| コンパイル時間 | 1,792 ms |
| コンパイル使用メモリ | 56,096 KB |
| 実行使用メモリ | 10,396 KB |
| 最終ジャッジ日時 | 2024-07-05 00:27:39 |
| 合計ジャッジ時間 | 9,979 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 RE * 1 TLE * 1 -- * 7 |
ソースコード
#include <iostream>
#include <string>
using namespace std;
int N,number[60],total;
int dp[60][100001];
bool sign=false;
string plus_times[61];
int recursion(int locate,int now){
if(sign)return sign;
if(dp[locate][now])return dp[locate][now];
if(now==total && locate==N )return sign=true;
if(locate==N)return sign;
bool response=false;
plus_times[locate]="+";
response|=recursion(locate+1,now+number[locate]);
if(response)
return dp[locate][now]=response;
plus_times[locate]="*";
response|=recursion(locate+1,now*number[locate]);
return dp[locate][now]=response;
}
int main(){
cin >> N >> total;
for(int i=0 ; i<N ; i++ )
cin >> number[i];
recursion(1,number[0]);
for(int i=0 ; i<N ; i++ )
cout << plus_times[i];
cout << endl;
return 0;
}
A63635985