結果

問題 No.396 クラス替え
ユーザー kichirb3
提出日時 2018-03-23 10:58:18
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 29 ms / 1,000 ms
コード長 767 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-06-24 21:03:37
合計ジャッジ時間 1,636 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
"""
No.396 クラス替え
https://yukicoder.me/problems/no/396

"""
import sys
from sys import stdin
input = stdin.readline


def check_class(a, b):
    res = -1
    q, r = divmod(a, b)
    if q % 2 == 0:
        if r == 0 or r == 1:
            res = 1
        else:
            res = r
    else:
        if r == 0 or r == 1:
            res = b
        else:
            res = b - r + 1
    return res

def solve(M, X, Y):
    hanako = check_class(X, M)
    taro = check_class(Y, M)

    if hanako == taro:
        return 'YES'
    else:
        return 'NO'

def main(args):
    N, M = map(int, input().split())
    X, Y = map(int, input().split())
    ans = solve(M, X, Y)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
0