結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
30,912 KB
testcase_01 AC 42 ms
31,092 KB
testcase_02 AC 41 ms
30,892 KB
testcase_03 AC 43 ms
30,784 KB
testcase_04 AC 41 ms
30,936 KB
testcase_05 AC 42 ms
30,936 KB
testcase_06 AC 41 ms
30,924 KB
testcase_07 AC 41 ms
30,728 KB
testcase_08 AC 42 ms
31,036 KB
testcase_09 AC 41 ms
30,820 KB
testcase_10 AC 42 ms
30,784 KB
testcase_11 AC 42 ms
30,948 KB
testcase_12 AC 41 ms
30,852 KB
testcase_13 AC 42 ms
30,856 KB
testcase_14 AC 42 ms
30,872 KB
testcase_15 AC 41 ms
30,820 KB
testcase_16 AC 41 ms
30,764 KB
testcase_17 AC 41 ms
30,992 KB
testcase_18 AC 42 ms
30,932 KB
testcase_19 AC 41 ms
30,860 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, $m);
$y = getClass($y, $m);

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

function getClass($x, $all) {
    $x = $x % ($all*2); // 往復を正規化
    if($x == 0) {$x = 1;} // 折り返しの終点が0になるが、これは1組と同等
    if($x > $all) { // 折り返し後の位置を正規化
        $x = $all - (($x % $all) -1);
    }
    return $x;
}
0