結果

問題 No.3260 岩井スターグラフ
ユーザー sgfc
提出日時 2025-09-07 21:19:16
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 367 ms / 2,000 ms
コード長 430 bytes
コンパイル時間 3,652 ms
コンパイル使用メモリ 275,016 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-07 21:19:32
合計ジャッジ時間 15,167 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ll = long long;

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

	ll x, y, n;
	cin >> x >> y >> n;
	
	for (int i=0; i<n; ++i) {
		ll u, v;
		cin >> u >> v;
		
		if (u == 0) {
			cout << (v - 1) % y + 1 << endl;
		}
		else {
			if ((u-1)/y == (v-1)/y) {
				cout << v - u << endl;
			}
			else {
				cout << (u-1)%y + 1 + (v-1)% y + 1 << endl;
			}
		}
		
	}

	
}
0