結果
問題 |
No.3260 岩井スターグラフ
|
ユーザー |
![]() |
提出日時 | 2025-09-06 13:49:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 369 ms / 2,000 ms |
コード長 | 1,946 bytes |
コンパイル時間 | 2,377 ms |
コンパイル使用メモリ | 195,212 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-06 13:49:24 |
合計ジャッジ時間 | 13,724 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 |
ソースコード
#include <bits/stdc++.h> #include <cmath> #include <algorithm> #include <vector> #include <iostream> #include <set> using namespace std; using ll = long long; using ull = unsigned long long; #define coutY cout << "Yes" << endl; #define coutN cout << "No" << endl; #define FOR(i,l,r) for(int i=l;i<r;++i) #define FORrev(i,l,r) for(int i=l;i>r;--i) #define arrIn(arr, start, N) for (int i = (start); i < (N); ++i) cin >> arr[i]; #define arrOut(arr, start, N) for (int i = (start); i < (N); ++i) { cout << arr[i] <<" "; } cout << endl; #define arrCopy(arr1,arr2, start, N) for (int i = (start); i < (N); ++i) arr2[i]= arr1[i]; #define partmax(arr, start, end) *max_element(arr.begin()+start,A.begin()+end); void yn(bool tf) { cout << (tf ? "Yes\n" : "No\n"); } void YN(bool tf) { cout << (tf ? "YES\n" : "NO\n"); } int CTI(char c){return (int)(c-'0');} string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //cout << fixed << setprecision(20) << int gcd(int a, int b){ //最大公約数 if(a%b == 0){ return b; }else{ return gcd(b, a%b); } } int lcm(int a, int b){ //最小公倍数 return a*b / gcd(a, b); } int nibun(const std::vector<int>& arr, int key, int begin, int end) { while (begin <= end) { int mid = (begin + end) / 2; if (arr[mid] == key) { return mid; } else if (arr[mid] < key) { begin = mid + 1; } else { end = mid - 1; } } return -1; } int fabs(int a,int b){ if(a-b>0){ return a-b; }else{ return b-a; } } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); #ifndef ONLINE_JUDGE ifstream in("b_input.txt"); cin.rdbuf(in.rdbuf()); #endif ll X,Y,N; cin >> X >> Y >> N; FOR(i,0,N){ 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+(V-1)%Y+2 << endl; } } } return 0; }