結果

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

ソースコード

diff #

import sys, time, random, heapq, math, itertools, copy
from collections import deque, Counter, defaultdict
from bisect import bisect, bisect_left, bisect_right
import heapq as hq
from functools import cache, cmp_to_key
def debug(*x):print('debug:',*x, file=sys.stderr)
sys.setrecursionlimit(300000)
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 61 - 1
mod = 998244353
dir = [(0, 1), (0, -1), (1, 0), (-1, 0)]

X, Y, N = mi()

for _ in range(N):
    u, v = mi()
    if u == 0 or v == 0:
        print((max(u, v) - 1) % Y + 1)
    else:
        if (u - 1) // Y  == (v - 1) // Y:
            print(abs(u - v))
        else:
            print((u - 1) % Y + 1 + (v - 1) % Y + 1)
    
0