結果

問題 No.281 門松と魔法(1)
ユーザー tails
提出日時 2015-09-18 23:06:45
言語 Perl
(5.40.0)
結果
WA  
実行時間 -
コード長 349 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 5,376 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-11-06 19:04:59
合計ジャッジ時間 1,756 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 37 WA * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

sub min{$_[0]<$_[1]?$_[0]:$_[1]}
sub max{$_[0]>$_[1]?$_[0]:$_[1]}
($d,$i,$h,$j)=<>;
exit!print $i<$h&&$j<$h||$i>$h&&$j>$h?0:-1 if $d==0;
$n=max(0,int(($h-min($i,$j)+$d)/$d));
$n=1e11 if $h-$d*$n<0;
$o=max(0,int(($i-$h+$d)/$d));
$o=1e11 if $i-$d*$o<0;
$p=max(0,int(($j-$h+$d)/$d));
$p=1e11 if $j-$d*$p<0;
$n=min($n,$o+$p);
$n=-1 if $n>=1e11;
print$n
0