結果

問題 No.10 +か×か
ユーザー ReERishunReERishun
提出日時 2020-05-10 01:56:50
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,074 bytes
コンパイル時間 1,004 ms
コンパイル使用メモリ 29,040 KB
実行使用メモリ 5,932 KB
最終ジャッジ日時 2023-09-20 17:27:54
合計ジャッジ時間 7,311 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<stdio.h>

typedef unsigned short ushort;

void numin(ushort index, ushort *numBox) {
	char str;
	for (ushort i = 0; i<index; i++)
		numBox[i] = 0;
	ushort cnt = 0;
	while (cnt < index) {
		str = getchar();
		if (str == '\n') {
			if (cnt != 0)
				break;
		}
		else if (str < '0' || str > '9')
			cnt++;
		else
			numBox[cnt] = numBox[cnt] * 10 + (ushort)str - (ushort)'0';
	}
}


int main() {
	ushort number=0;
	ushort total =0;
	ushort value[50];

	scanf("%hu", &number);
	scanf("%hu", &total);

	numin(number, value);

	ushort ans = value[0];
	ushort cnt = 2;
	unsigned long long switcher = 5;

	while (1) {
		if ((switcher >> cnt) & 1)
			ans *= value[cnt + 1];
		else
			ans += value[cnt + 1];

		if (cnt == number - 2) {
			if (ans == total)
				break;
			else {
				ans = value[0];
				cnt = 0;
				switcher++;
				continue;
			}
		}else if (ans >= total) {
			ans = value[0];
			cnt = 0;	
			switcher++;
			continue;
		}
		cnt++;
	}
	
	for (int i = 0; i < number - 1; i++) {
		if((switcher >> i) & 1)
			printf("*");
		else
			printf("+");
	}


	return 0;
}
0