結果

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

ソースコード

diff #

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

using ll = int64_t;

ll X, Y, N;
vector<ll> U, V;

void input() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> X >> Y >> N;
    U.resize(N), V.resize(N);
    for (ll i=0; i<N; ++i) cin >> U[i] >> V[i];
}

void solve() {
    for (ll i=0; i<N; ++i) {
        if (U[i] == 0) {
            cout << (V[i]-1) % Y + 1 << "\n";
        } else if ((U[i]-1) / Y == (V[i]-1) / Y) {
            cout << V[i] - U[i] << "\n";
        } else {
            cout << (U[i]-1) % Y + (V[i]-1) % Y + 2 << "\n";
        }
    }
}

int main() {
    input();
    solve();
    return 0;
}

/* 考察

*/
0