結果

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

ソースコード

diff #

X,Y,N=map(int,input().split())
for i in range(N):
    U,V=map(int,input().split())
    if U==0 and V==0:
        print(0)
    elif 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