답안 #130299

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
130299 2019-07-14T17:22:11 Z osaaateiasavtnl 이상한 기계 (APIO19_strange_device) C++14
5 / 100
2 ms 420 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n, A, B, D;

int get(int n) {
    return min(n, D);
}   

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n >> A >> B;
    D = A / __gcd(A, B + 1);

    if (n != 1) {
        exit(1);
    }   

    {
        int l, r;
        cin >> l >> r;
        
        if (l / B == r / B) {
            cout << r - l + 1 << '\n';
            exit(0);
        }   

        int l1 = ((l + B - 1) / B) * B;
        int r1 = (r / B) * B - 1;

        int c = 0;
        if (l1 <= r1) {
            c = (r1 - l1 + 1) / B;
        }   

        // [l % B; B - 1]
        // [0; r % B]

        int tl = r % B, tr = l % B;
        
        if (tl < tr) {
            int len = tr - tl - 1;
            cout << get(c) * len + get(c + 1) * (B - len) << '\n';
        }   
        else {
            int len = tl - tr + 1;
            cout << get(c + 2) * len + get(c + 1) * (B - len) << '\n';
        }   
    }   
}   
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 420 KB Output is correct
2 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 252 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Runtime error 1 ms 376 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 420 KB Output is correct
2 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -