結果

問題 No.10 +か×か
ユーザー cielciel
提出日時 2014-11-17 16:03:56
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 502 bytes
コンパイル時間 1,504 ms
コンパイル使用メモリ 49,500 KB
実行使用メモリ 7,280 KB
最終ジャッジ日時 2023-08-30 20:24:18
合計ジャッジ時間 8,268 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
using namespace std;
void dfs(int total,int cur,vector<int> &v,string s){
	if(s.size()==v.size()-1){
		if(cur==total){
			puts(s.c_str());
			exit(0);
		}
		return;
	}
	if(cur>total)return;
	dfs(total,cur+v[s.size()+1],v,s+'+');
	dfs(total,cur*v[s.size()+1],v,s+'*');
}

int main(){
	int n,total;
	scanf("%d%d",&n,&total);
	vector<int>v(n);
	for(int i=0;i<n;i++)scanf("%d",&v[i]);
	dfs(total,v[0],v,"");
}
0