結果

問題 No.10 +か×か
ユーザー A63635985A63635985
提出日時 2018-03-03 23:10:44
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 921 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 53,008 KB
実行使用メモリ 7,812 KB
最終ジャッジ日時 2023-09-18 08:32:53
合計ジャッジ時間 7,376 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 RE -
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0