結果

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

int main(void){
  ll x, y, n; cin >> x >> y >> n;
  while(n--){
    ll u, v; cin >> u >> v;
    if(u==0){
      cout << (v-1)%y+1 << '\n';
    }
    else{
      int ui=(u-1)/y, vi=(v-1)/y;
      if(ui==vi){
        cout << v-u << '\n';
      }
      else{
        cout << (u-1)%y+(v-1)%y+2 << '\n';
      }
    }
  }
  return 0;
}
0