답안 #721502

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
721502 2023-04-11T03:19:08 Z GrandTiger1729 이상한 기계 (APIO19_strange_device) C++17
0 / 100
5000 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;

const int INF = 1e18 + 10;
int main(){
    cin.tie(0)->sync_with_stdio(0);
    int n; cin >> n;
    long long A, B; cin >> A >> B;
    if ((__int128_t)1 * A * B / __gcd(A, B + 1) >= INF){
        long long ans = 0;
        for (int i = 0; i < n; i++){
            long long l, r; cin >> l >> r;
            ans += r - l + 1;
        }
        cout << ans << '\n';
        return 0;
    }
    long long D = (__int128_t)1 * A * B / __gcd(A, B + 1);
    set<long long> st;
    for (int i = 0; i < n; i++){
        long long l, r; cin >> l >> r;
        for (int j = l; j <= r; j++)
            st.insert(j % D);
    }
    // cerr << D << '\n';
    // for (auto &v: st)
    //     cerr << v << ' ';
    // cerr << endl;
    cout << st.size() << '\n';
    return 0;
}

Compilation message

strange_device.cpp:4:22: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
    4 | const int INF = 1e18 + 10;
      |                 ~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 5059 ms 304000 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 4016 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 Execution timed out 5051 ms 45548 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 5025 ms 58268 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 5025 ms 58268 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 5025 ms 58268 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 4231 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 Execution timed out 5059 ms 304000 KB Time limit exceeded
3 Halted 0 ms 0 KB -