結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
	ll x,y,n;
	cin>>x>>y>>n;
	while(n--){
		ll u,v;
		cin>>u>>v;
		if(u>v)swap(u,v);
		if(u==0){
			cout<<(v-1)%y+1<<endl;	
		}else 
		if((u-1)/y==(v-1)/y){
			//cout<<"1"<<endl;
			cout<<abs(u-v)<<endl;
		}else{
			//cout<<"2"<<endl;
			cout<<(u-1)%y+(v-1)%y+2<<endl;
		}
	}
}
0