結果

問題 No.2069 み世界数式
ユーザー tailstails
提出日時 2022-09-09 14:21:49
言語 Perl
(5.38.2)
結果
AC  
実行時間 601 ms / 2,000 ms
コード長 575 bytes
コンパイル時間 884 ms
コンパイル使用メモリ 7,020 KB
実行使用メモリ 6,024 KB
最終ジャッジ日時 2023-08-16 20:55:03
合計ジャッジ時間 4,811 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,148 KB
testcase_01 AC 5 ms
5,256 KB
testcase_02 AC 6 ms
5,256 KB
testcase_03 AC 5 ms
5,212 KB
testcase_04 AC 5 ms
5,272 KB
testcase_05 AC 5 ms
5,292 KB
testcase_06 AC 5 ms
5,208 KB
testcase_07 AC 6 ms
5,164 KB
testcase_08 AC 5 ms
5,208 KB
testcase_09 AC 6 ms
5,164 KB
testcase_10 AC 5 ms
5,116 KB
testcase_11 AC 7 ms
5,432 KB
testcase_12 AC 14 ms
5,556 KB
testcase_13 AC 17 ms
5,572 KB
testcase_14 AC 14 ms
5,764 KB
testcase_15 AC 23 ms
5,596 KB
testcase_16 AC 33 ms
5,712 KB
testcase_17 AC 23 ms
5,632 KB
testcase_18 AC 26 ms
6,024 KB
testcase_19 AC 26 ms
5,812 KB
testcase_20 AC 56 ms
5,808 KB
testcase_21 AC 14 ms
5,408 KB
testcase_22 AC 50 ms
6,000 KB
testcase_23 AC 34 ms
5,880 KB
testcase_24 AC 28 ms
5,676 KB
testcase_25 AC 63 ms
5,788 KB
testcase_26 AC 33 ms
5,972 KB
testcase_27 AC 6 ms
5,292 KB
testcase_28 AC 6 ms
5,400 KB
testcase_29 AC 5 ms
5,136 KB
testcase_30 AC 5 ms
5,108 KB
testcase_31 AC 5 ms
5,256 KB
testcase_32 AC 5 ms
5,296 KB
testcase_33 AC 6 ms
5,296 KB
testcase_34 AC 5 ms
5,224 KB
testcase_35 AC 5 ms
5,260 KB
testcase_36 AC 5 ms
5,164 KB
testcase_37 AC 96 ms
5,880 KB
testcase_38 AC 601 ms
5,812 KB
testcase_39 AC 20 ms
5,356 KB
testcase_40 AC 10 ms
5,488 KB
testcase_41 AC 7 ms
5,400 KB
testcase_42 AC 9 ms
5,544 KB
testcase_43 AC 9 ms
5,548 KB
testcase_44 AC 15 ms
5,688 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

($m,$ans)=glob<>;
$_=<>;
0while
s{(\w+)|(&)\B(?![(])|(\$)\B(?![&(])|(\(\))}{
	if(defined$1){
		push@a,{$1,$1};
	}
	if($2|$3){
		$b=pop@a;
		$a=pop@a;
		push@a,$r={};
		for$x(keys%$a){
			$u=$$a{$x};
			for$y(keys%$b){
				$v=$$b{$y};
				if($2){
					if($y!=0){
						$$r{int$x/$y}="$u/$v";
					}
					if($x*$y<=$m){
						$$r{$x*$y}="$u*$v";
					}
				}
				if($3){
					if($x-$y>=0){
						$$r{$x-$y}="$u-$v";
					}
					if($x+$y<=$m){
						$$r{$x+$y}="$u+$v";
					}
				}
			}
		}
	}
	if($4){
		for(values%{$a[-1]}){
			$_="($_)";
		}
	}
}e;
print$a[0]{$ans}||-1,$/;
0