結果
問題 |
No.3260 岩井スターグラフ
|
ユーザー |
|
提出日時 | 2025-09-06 13:11:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 533 ms / 2,000 ms |
コード長 | 1,197 bytes |
コンパイル時間 | 3,995 ms |
コンパイル使用メモリ | 252,832 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-06 13:14:30 |
合計ジャッジ時間 | 18,637 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using namespace std; // using mint = atcoder::modint998244353; using ll = long long; const int INF = 1001001001; const ll LINF = 3001001001001001001; const int MOD = 998244353; const string Yes = "Yes"; const string No = "No"; #define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i) #define rep(i, n) reps(i, 0, n) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;} template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;} template <typename T> istream &operator>>(istream &is, vector<T> &v) {for (T &in : v)is >> in;return is;} vector<pair<int,int>> dir4 = {{0,1},{0,-1},{1,0},{-1,0},}; vector<pair<int,int>> dir8 = {{0,1},{0,-1},{1,0},{-1,0},{-1,-1},{-1,1},{1,-1},{1,1},}; int main() { ll x,y;cin>>x>>y; int Q;cin>>Q; while(Q--) { ll u,v;cin>>u>>v; ll s = u%y; if(u!=0&&u%y==0) s = y; ll t = v%y; if(v!=0&&v%y==0) t = y; if((u-1)/y==(v-1)/y) { cout << abs(s-t) << endl; } else { cout << s+t << endl; } } return 0; }