답안 #216992

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
216992 2020-03-28T16:34:16 Z sevlll 이상한 기계 (APIO19_strange_device) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define pb push_back
#define int long long
#define str string
using namespace std;
const int M = 1e9 + 7;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, a, b;
    cin >> n >> a >> b;
    vector<pair<int, int>> pr(n);
    for (int i = 0; i < n; i++) cin >> pr[i].first >> pr[i].second;
    int g = gcd(a, b+1);
    a /= g;
    if (a * b >= 1e18+8800) {
        int ans = 0;
        for (auto p : pr) {
            ans += p.second - p.first+1;
        }
        cout << ans;
        return 0;
    }
    int ans = 0;
    set<int> ses;
    for (auto p : pr) {
        int l = p.first, r = p.second;
        if (l == r) {
            ses.insert(l%(a*b));
        } else {
            l %= (a * b);
            r %= (a * b);
            if (r <= l) r += a * b;
            for (int x = l; x <= r; x++) {
                ses.insert(x % (a * b));
            }
        }
    }
    cout << ses.size();
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:36:13: error: 'gcd' was not declared in this scope
     int g = gcd(a, b+1);
             ^~~
strange_device.cpp:36:13: note: suggested alternative: 'gcvt'
     int g = gcd(a, b+1);
             ^~~
             gcvt
strange_device.cpp:46:9: warning: unused variable 'ans' [-Wunused-variable]
     int ans = 0;
         ^~~