結果
| 問題 |
No.281 門松と魔法(1)
|
| コンテスト | |
| ユーザー |
tails
|
| 提出日時 | 2015-09-18 23:59:02 |
| 言語 | Perl (5.40.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 546 bytes |
| コンパイル時間 | 46 ms |
| コンパイル使用メモリ | 5,248 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-11-06 19:31:06 |
| 合計ジャッジ時間 | 1,622 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 53 WA * 4 |
コンパイルメッセージ
Name "main::h1" used only once: possible typo at Main.pl line 8. Main.pl syntax OK
ソースコード
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=min($i,$j)==0?1e11:max(0,int(($h-min($i,$j)+$d)/$d));
$o=$h==0?1e11:max(0,int(($i-$h+$d)/$d));
$p=$h==0?1e11:max(0,int(($j-$h+$d)/$d));
$h1=max(0,$h-$d*$n);
$i1=max(0,$i-$d*$o);
$j1=max(0,$j-$d*$p);
if($i==$j){
if($i==0){
$n=1e11;
}else{
++$n;
if($i-$d<=$h){
++$n;
if($h-$d<0){
$n=1e11;
}
}
}
}
$o=$i1==0?1e11:$o+1 if $i1==$j1;
$n=min($n,$o+$p);
$n=-1 if $n>=1e11;
print$n
tails