結果

問題 No.10 +か×か
ユーザー akakimidoriakakimidori
提出日時 2015-07-27 01:53:30
言語 C90
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 465 bytes
コンパイル時間 201 ms
コンパイル使用メモリ 24,020 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-23 03:37:23
合計ジャッジ時間 8,138 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<stdio.h>

int dfs(int now,int total,int *A,int num,char *s){
	if(num==0){
		s[0]='\0';
		return now==total;
	}
	if(now>total) return 0;

	s[0]='+';
	int res=dfs(now+A[0],total,A+1,num-1,s+1);
	if(res) return 1;
	s[0]='*';
	return dfs(now*A[0],total,A+1,num-1,s+1);
}

int main(void){
	int N,total;
	scanf("%d%d",&N,&total);

	int A[50];
	int i;
	for(i=0;i<N;i++) scanf("%d",&A[i]);

	char s[55];
	dfs(A[0],total,A+1,N-1,s);
	printf("%s\n",s);
	return 0;
}
0