結果
問題 |
No.3260 岩井スターグラフ
|
ユーザー |
![]() |
提出日時 | 2025-09-06 13:09:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 76 ms / 2,000 ms |
コード長 | 3,255 bytes |
コンパイル時間 | 4,295 ms |
コンパイル使用メモリ | 249,848 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2025-09-06 13:11:05 |
合計ジャッジ時間 | 9,175 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; #define ALL(a) (a).begin(), (a).end() #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rrep(i, n) for (ll i = (n) - 1; i >= 0; --i) #define foreach(i, n) for (auto i : (n)) #define chmax(a, b) a = max(a, b) #define chmin(a, b) a = min(a, b) #define popcount __builtin_popcountll using mint = modint998244353; using mint1 = modint1000000007; template <typename K, typename V> using umap = std::unordered_map<K, V>; template <typename K> using uset = std::unordered_set<K>; // 参考元 : https://qiita.com/ganyariya/items/df35d253726269bda436 struct HashPair { //注意 constがいる template<class T1, class T2> size_t operator()(const pair<T1, T2> &p) const { //first分をハッシュ化する auto hash1 = hash<T1>{}(p.first); //second分をハッシュ化する auto hash2 = hash<T2>{}(p.second); //重複しないようにハッシュ処理 size_t seed = 0; seed ^= hash1 + 0x9e3779b9 + (seed << 6) + (seed >> 2); seed ^= hash2 + 0x9e3779b9 + (seed << 6) + (seed >> 2); return seed; } }; template <typename X, typename Y> using pair_map = unordered_map<pair<X, Y>, ll, HashPair>; template <typename X, typename Y> using pair_set = unordered_set<pair<X, Y>, HashPair>; template <typename T> using v = vector<T>; template <typename T> using vv = v<v<T>>; template <typename T> using vvv = vv<v<T>>; template <typename T, typename U> using P = pair<T, U>; using grid = vector<vector<char>>; using graph = vector<vector<int>>; using vi = vector<int>; using vvi = vector<vector<int>>; using vvvi = vector<vector<vector<int>>>; using vl = vector<ll>; using vvl = vector<vector<ll>>; using vvvl = vector<vector<vector<ll>>>; using vm = vector<mint>; using vvm = vector<vector<mint>>; using vvvm = vector<vector<vector<mint>>>; using vm1 = vector<mint1>; using vvm1 = vector<vector<mint1>>; using vvvm1 = vector<vector<vector<mint1>>>; using vld = vector<ld>; using vvld = vector<vector<ld>>; using vvvld = vector<vector<vector<ld>>>; using vb = vector<bool>; using vvb = vector<vector<bool>>; using vs = vector<string>; using vvs = vector<vector<string>>; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll x, y, n; cin >> x >> y >> n; rep(i, n) { ll u, v; cin >> u >> v; if (u == 0) { ll d = v % y; if (d == 0) d = y; cout << d << "\n"; continue; } if (v == 0) { ll d = u % y; if (d == 0) d = y; cout << d << "\n"; continue; } ll u_a = u / y; ll v_a = v / y; ll u_d = u % y; ll v_d = v % y; if (u_d == 0) { u_d = y; u_a--; } if (v_d == 0) { v_d = y; v_a--; } if (u_a == v_a) { ll d = abs(u_d - v_d); cout << d << "\n"; continue; } else { cout << u_d + v_d << "\n"; } } return 0; }