結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2020-01-21 18:59:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 714 bytes |
| コンパイル時間 | 594 ms |
| コンパイル使用メモリ | 69,376 KB |
| 実行使用メモリ | 8,704 KB |
| 最終ジャッジ日時 | 2024-07-06 00:08:56 |
| 合計ジャッジ時間 | 6,931 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 TLE * 1 -- * 7 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n,z;
int a[50];
string A;
string Z;
int dfs(int nw,int j){
//cout << nw << " " << j << " " << A << endl;
if(j == n){
if(z==nw){
Z = A;
return 1;
}
return 0;
}
if(nw+a[j] <= z){
A.push_back('+');
if(dfs(nw+a[j],j+1)){
return 1;
};
A.pop_back();
}
if(nw*a[j] <= z){
A.push_back('*');
if(dfs(nw*a[j],j+1)){
return 1;
};
A.pop_back();
}
return 0;
}
int main(){
cin>>n>>z;
for(int i = 0; n > i; i++){
cin>>a[i];
}
dfs(a[0],1);
cout << Z << endl;
}