結果

問題 No.10 +か×か
ユーザー kyuridenamidakyuridenamida
提出日時 2016-02-10 19:31:39
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 440 bytes
コンパイル時間 1,613 ms
コンパイル使用メモリ 159,172 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-16 19:06:16
合計ジャッジ時間 2,034 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int dfs(int, int)’:
main.cpp:19:20: warning: control reaches end of non-void function [-Wreturn-type]
   19 |                 dfs(x+1,r*a[x]);
      |                 ~~~^~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int dn[55][100010];
int tot,N;
int a[55];
char res[55];
int dfs(int x,int r){
	if( r > tot ) return 0;
	if( dn[x][r]++ ) return 0;
	if( r == tot && x == N ){
		cout << res << endl;
		exit(0);
	}else{
		if( N == x ) return 0;
		res[x-1] = '+';
		dfs(x+1,r+a[x]);
		res[x-1] = '*';
		dfs(x+1,r*a[x]);
	}
}

int main(){
	cin >> N >> tot;
	for(int i = 0 ; i < N ; i++) cin >> a[i];
	dfs(1,a[0]);
}
0