답안 #683644

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
683644 2023-01-19T04:29:13 Z Nursik 이상한 기계 (APIO19_strange_device) C++14
컴파일 오류
0 ms 0 KB
#include <stdio.h>
 
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
 
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ld long double
#define bug cout << "bug\n";

const ll maxn = 2e5 + 5, maxm = 2e2 + 1;
const ll mod = 1e9 + 7, inf = 1e9, block = 550, hb = 126067, base = 1000050017,
         biginf = 5e18;
const ld eps = 1e-15;
using namespace std;

int n;
ll a, b;
ll l[maxn], r[maxn];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n >> a >> b;
    ll p = a * b / gcd(a, b + 1);
    vector<pair<ll, ll>> v;
    for (int i = 1; i <= n; ++i){
        cin >> l[i] >> r[i];
        ll x = l[i] % p;
        ll y = r[i] % p;
        if (x <= y){
            v.pb(mp(x, y));
        }
        else{
            v.pb(mp(x, p - 1));
            v.pb(mp(0, y));
        }
    }
    sort(v.begin(), v.end());
    ll ans = 0, nxt = -1;
    for (auto it : v){
        int l = it.f, r = it.s;
        if (nxt < l){
            ans += r - l + 1;
            nxt = r;
        }
        else if (nxt <= r){
            ans += r - nxt;
            nxt = r;
        }
    }
    cout << ans;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:51:20: error: 'gcd' was not declared in this scope
   51 |     ll p = a * b / gcd(a, b + 1);
      |                    ^~~