結果

問題 No.3260 岩井スターグラフ
コンテスト
ユーザー srjywrdnprkt
提出日時 2025-10-20 15:33:36
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 654 bytes
コンパイル時間 2,593 ms
コンパイル使用メモリ 275,688 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-20 15:33:46
合計ジャッジ時間 9,818 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/modint>

using namespace std;
//using namespace atcoder;
using ll = long long;
//using mint = modint998244353;

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    ll X, Y, N;
    cin >> X >> Y >> N;
    while(N--){
        ll U, V, uq, ur, vq, vr;
        cin >> U >> V;
        if (U == 0){
            cout << (V-1) % Y + 1 << '\n';
            continue;
        }
        U--; V--;
        uq = U / Y;
        ur = U % Y + 1;
        vq = V / Y;
        vr = V % Y + 1;
        if (uq == vq) cout << abs(ur-vr) << '\n';
        else cout << ur+vr << '\n';

    }

    return 0;
}
0