結果

問題 No.3260 岩井スターグラフ
ユーザー iastm
提出日時 2025-09-06 13:05:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 638 ms / 2,000 ms
コード長 322 bytes
コンパイル時間 345 ms
コンパイル使用メモリ 82,716 KB
実行使用メモリ 77,952 KB
最終ジャッジ日時 2025-09-06 13:06:28
合計ジャッジ時間 18,878 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

X, Y, N = (int(x) for x in input().split())
for _ in range(N):
    U, V = (int(x) for x in input().split())
    if U == 0:
        print((V - 1) % Y + 1)
    elif V == 0:
        print((U - 1) % Y + 1)
    elif (U - 1) // Y == (V - 1) // Y:
        print(abs(U - V))
    else:
        print((U - 1) % Y + (V - 1) % Y + 2)
0