結果

問題 No.396 クラス替え
ユーザー papinianuspapinianus
提出日時 2016-09-01 09:45:11
言語 PHP
(8.3.4)
結果
AC  
実行時間 49 ms / 1,000 ms
コード長 551 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 30,912 KB
実行使用メモリ 31,092 KB
最終ジャッジ日時 2024-04-28 17:20:12
合計ジャッジ時間 1,745 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
31,092 KB
testcase_01 AC 44 ms
31,016 KB
testcase_02 AC 45 ms
30,884 KB
testcase_03 AC 43 ms
31,024 KB
testcase_04 AC 43 ms
30,924 KB
testcase_05 AC 47 ms
30,924 KB
testcase_06 AC 43 ms
30,924 KB
testcase_07 AC 41 ms
30,712 KB
testcase_08 AC 41 ms
31,040 KB
testcase_09 AC 42 ms
30,868 KB
testcase_10 AC 41 ms
30,776 KB
testcase_11 AC 42 ms
30,932 KB
testcase_12 AC 41 ms
30,876 KB
testcase_13 AC 42 ms
30,844 KB
testcase_14 AC 42 ms
30,988 KB
testcase_15 AC 42 ms
31,028 KB
testcase_16 AC 42 ms
30,664 KB
testcase_17 AC 41 ms
30,700 KB
testcase_18 AC 41 ms
30,868 KB
testcase_19 AC 42 ms
30,980 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
list($null, $m) = explode(" ",trim(fgets(STDIN)));
list($x, $y) = explode(" ",trim(fgets(STDIN)));
$x = getClass($x-1, $m); //modのためにマイナス
$y = getClass($y-1, $m);

if($x == $y) {
    echo "YES";
} else {
    echo "NO";
}
echo PHP_EOL;

function getClass($x, $all) {
    $x = $x % ($all*2); // 往復を正規化
    if($x >= $all) { // 折り返し後の位置を正規化 -1しているので$all以降が折り返し
        $x = $all -1 - ($x % $all); //$all - 1が右端、そこから何組戻るか
    }
    return $x;
}
0