# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
729648 | 2023-04-24T10:25:29 Z | danikoynov | 이상한 기계 (APIO19_strange_device) | C++14 | 5000 ms | 524288 KB |
#include<bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } const int maxn = 1e6 + 10; int n; ll l[maxn], r[maxn]; ll A, B; void solve() { cin >> n >> A >> B; for (int i = 1; i <= n; i ++) { cin >> l[i] >> r[i]; } ll g = __gcd(A, B + 1); /// period is A * B / g if ((double)(1e18) / (double)(A) < (double)(B) / (double)(g)) { ll ans = 0; for (int i = 1; i <= n; i ++) { ans = ans + (r[i] - l[i] + 1); } cout << ans << endl; return; } double period = A * B / g; unordered_set < ll > st; for (int i = 1; i <= n; i ++) { for (ll j = l[i]; j <= r[i]; j ++) { ll x = (j + (j / B)) % A, y = j % B; ///cout << x << " " << y << endl; st.insert(x * B + y); } } cout << st.size() << endl; } int main() { solve(); return 0; } /** 1 10000 3312452154131231 1 1 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 37 ms | 10200 KB | Output is correct |
3 | Correct | 48 ms | 12400 KB | Output is correct |
4 | Correct | 2 ms | 556 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 2 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 4 ms | 852 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 304 KB | Output is correct |
12 | Correct | 1 ms | 304 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 16 ms | 4964 KB | Output is correct |
16 | Correct | 22 ms | 5472 KB | Output is correct |
17 | Correct | 150 ms | 7580 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Runtime error | 696 ms | 524288 KB | Execution killed with signal 9 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 304 KB | Output is correct |
2 | Correct | 60 ms | 21916 KB | Output is correct |
3 | Correct | 80 ms | 21796 KB | Output is correct |
4 | Correct | 66 ms | 20996 KB | Output is correct |
5 | Execution timed out | 5035 ms | 58644 KB | Time limit exceeded |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1342 ms | 58948 KB | Output is correct |
3 | Runtime error | 2155 ms | 524288 KB | Execution killed with signal 9 |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1342 ms | 58948 KB | Output is correct |
3 | Runtime error | 2155 ms | 524288 KB | Execution killed with signal 9 |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1342 ms | 58948 KB | Output is correct |
3 | Runtime error | 2155 ms | 524288 KB | Execution killed with signal 9 |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Runtime error | 2728 ms | 524288 KB | Execution killed with signal 9 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 37 ms | 10200 KB | Output is correct |
3 | Correct | 48 ms | 12400 KB | Output is correct |
4 | Correct | 2 ms | 556 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 2 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 4 ms | 852 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 304 KB | Output is correct |
12 | Correct | 1 ms | 304 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 16 ms | 4964 KB | Output is correct |
16 | Correct | 22 ms | 5472 KB | Output is correct |
17 | Correct | 150 ms | 7580 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Runtime error | 696 ms | 524288 KB | Execution killed with signal 9 |
21 | Halted | 0 ms | 0 KB | - |