結果

問題 No.10 +か×か
ユーザー kaffelunkaffelun
提出日時 2017-08-26 09:43:52
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 456 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 26,480 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-05 20:33:32
合計ジャッジ時間 1,061 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <cstdio>
using namespace std;
int main() {
	int N, T, b;
	scanf("%d %d", &N, &T);
	int *A = new int[N];
	for(int i = 0; i < N; i++) scanf("%d", A + i);
	N--;
	int Loop = 1 << N;
	for(b = 0; b < Loop; b++) {
		int S = A[0];
		for(int i = 0; i < N; i++) {
			if(b >> i & 1) S *= A[i + 1];
			else S += A[i + 1];
		}
		if(S == T) break;
	}
	for(int i = 0; i < N; i++) {
		if(b >> i & 1) printf("*");
		else printf("+");
	}
	printf("\n");
	return 0;
}
0