結果

問題 No.297 カードの数式
ユーザー tailstails
提出日時 2015-11-06 22:44:56
言語 Perl
(5.38.2)
結果
WA  
実行時間 -
コード長 468 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 5,340 KB
実行使用メモリ 4,940 KB
最終ジャッジ日時 2023-10-11 14:41:35
合計ジャッジ時間 1,278 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,680 KB
testcase_01 AC 3 ms
4,712 KB
testcase_02 AC 3 ms
4,816 KB
testcase_03 AC 3 ms
4,816 KB
testcase_04 AC 3 ms
4,684 KB
testcase_05 AC 3 ms
4,616 KB
testcase_06 AC 3 ms
4,796 KB
testcase_07 AC 2 ms
4,616 KB
testcase_08 AC 2 ms
4,548 KB
testcase_09 AC 2 ms
4,676 KB
testcase_10 AC 2 ms
4,588 KB
testcase_11 AC 2 ms
4,684 KB
testcase_12 AC 2 ms
4,624 KB
testcase_13 AC 3 ms
4,628 KB
testcase_14 AC 2 ms
4,644 KB
testcase_15 AC 2 ms
4,528 KB
testcase_16 AC 3 ms
4,796 KB
testcase_17 AC 3 ms
4,768 KB
testcase_18 AC 2 ms
4,680 KB
testcase_19 AC 2 ms
4,888 KB
testcase_20 WA -
testcase_21 AC 3 ms
4,764 KB
testcase_22 AC 3 ms
4,796 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Name "main::i" used only once: possible typo at Main.pl line 42.
Main.pl syntax OK

ソースコード

diff #

<>;@b=@a=sort<>=~/\S/g;

$y=0;
while($a[0]eq'+'){
	++$p;
	shift@a;
}
while($a[0]eq'-'){
	++$m;
	shift@a;
}
while($m){
	$y-=shift@a;
	--$m;
}
while($p){
	$y+=shift@a;
	--$p;
}
$y+=join'',reverse@a;

$z=$p=$m=0;
while($b[0]eq'+'){
	++$p;
	shift@b;
}
while($b[0]eq'-'){
	++$m;
	shift@b;
}
if($m){
	while($p>=0){
		$z+=shift@b;
		--$p;
	}
	while($m>1){
		$z-=shift@b;
		--$m;
	}
	$z-=join'',reverse@b;
}else{
	$c[$i++%($p+1)].=$_ for@b;
	$z=eval join'+',@c;
}
print"$y $z"
0