結果

問題 No.3260 岩井スターグラフ
ユーザー t98slider
提出日時 2025-09-06 13:07:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 735 bytes
コンパイル時間 1,867 ms
コンパイル使用メモリ 195,124 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-09-06 13:08:05
合計ジャッジ時間 6,680 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x, y, n;
    cin >> x >> y >> n;
    while(n--){
        ll u, v;
        cin >> u >> v;
        if(u == v){
            cout << "0\n";
            continue;
        }
        if(u == 0){
            cout <<  (v - 1) % y + 1 << '\n';
            continue;
        }
        if(v == 0){
            cout <<  (u - 1) % y + 1 << '\n';
            continue;
        }
        u--, v--;
        ll d0 = u / y, d1 = v / y;
        if(d0 == d1){
            cout << abs(u - v) << '\n';
        }else{
            u %= y, v %= y;
            u++, v++;
            cout << u + v << '\n';
        }
    }
}
0