結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(a) (a).begin(), (a).end()
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define endl '\n'

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll X, Y, N;
    cin >> X >> Y >> N;
    for (; N--;) {
        ll U, V;
        cin >> U >> V;
        ll ans;
        if ((U - 1) / Y == (V - 1) / Y) {
            ans = abs(((U % Y == 0 && U != 0) ? Y : U % Y) -
                      ((V % Y == 0 && V != 0) ? Y : V % Y));
        } else {
            ans = ((U % Y == 0 && U != 0) ? Y : U % Y) +
                  ((V % Y == 0 && V != 0) ? Y : V % Y);
        }
        cout << ans << endl;
    }
}
0