結果

問題 No.3260 岩井スターグラフ
ユーザー tkykwtnb
提出日時 2025-09-06 13:10:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 599 ms / 2,000 ms
コード長 316 bytes
コンパイル時間 386 ms
コンパイル使用メモリ 82,772 KB
実行使用メモリ 77,152 KB
最終ジャッジ日時 2025-09-06 13:12:59
合計ジャッジ時間 17,684 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

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