# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
382930 | 2021-03-28T14:31:53 Z | abil | 이상한 기계 (APIO19_strange_device) | C++14 | 377 ms | 16876 KB |
#include <bits/stdc++.h> #define SPEEDUP ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); #define fr first #define sc second #define pb push_back #define mk make_pair #define all(s) s.begin(),s.end() #define int long long using namespace std; const int N = (1e6 + 12); const int mod = (1e9 + 7); const int inf = (1e18 + 7); int l[N], r[N]; main(){ SPEEDUP; int n, A, B; cin >> n >> A >> B; // for(int i = 1; i <= 25; i++){ // cout << i << " "; // } // cout << endl; // vector<int > vec; // for(int i = 0;i <= 25; i++){ // cout << ((i + (i + B - 1) / B)) << " "; // vec.pb(((i + (i + B - 1) / B))); // } // cout << endl; // for(int i = 0;i <= 30; i++){ // cout << (i % B) << " "; // } // cout << endl; // for(auto to : vec){ // cout << to % A << " "; // } // cout << endl; for(int i = 1; i <= n; i++){ cin >> l[i] >> r[i]; } int x; int L = r[1] - l[1] + 1ll; if(0 == (A % (B + 1ll))){ if(inf / B >= (A / (B + 1ll))){ x = B * (A / (B + 1ll)); } else{ cout << L << endl; return 0; } } else{ if(inf / A >= B){ x = A * B; } else{ cout << L << endl; return 0; } } if(x <= L){ cout << x << endl; return 0; } int ans; if(r[1] % x >= l[1] % x){ ans = r[1] % x - l[1] % x + 1; } else{ ans = r[1] % x + 1 + (x - l[1] % x + 1); } cout << ans << endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 5 ms | 876 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 377 ms | 16876 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 377 ms | 16876 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 377 ms | 16876 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 364 KB | Output is correct |
2 | Incorrect | 37 ms | 2412 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 5 ms | 876 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |