Submission #564323

# Submission time Handle Problem Language Result Execution time Memory
564323 2022-05-18T23:44:14 Z pvpwarrior Strange Device (APIO19_strange_device) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define vi std::vector<ll>
#define si set<ll>
#define INF 100000000
#define pb push_back
#define mod 1000000007

ll solve(){
    ll n,a,b;
    cin >> n >> a >>b;
    si t;
    for (int i = 0; i < n; ++i)
    {
        ll l,r;
        cin >> l >> r;
        for (int j = l; j <= r; ++j){
            t.insert(j);
        }
    }
    set<pair <ll, ll> > ans;
    ll sum = 0;
    for(auto c: t){
        ll x = (c/b);
        x += c;
        x %= a;
        ll y= c%b;
        cout << c << " ";
        if(ans.count(make_pair(x,y))){
            cout << x << " " << y << " alr present\n";
        }
        else cout << x << " " << y << "\n";
        ans.insert(make_pair(x,y));
        
        sum ++;
    }
    cout << "\n";
    // for(auto x: ans){
    //     cout << x.first << " " << x.second << "\n";
    // }
    cout <<  ans.size();
    
    return 0;
}

ll solve2(){
    ll n,a,b;
    cin >> n >> a >>b;
    si t;
    ll q = b+1;
    ll z = a;
    ll hc = gcd(q,z);
    q/= hc;
    z/= hc;
    ll p = z*b;
    // cout << p;

    for (int i = 0; i < n; ++i)
    {
        ll l,r;
        cin >> l >> r;
        for (int j = l; j <= r; ++j){
            t.insert(j%p);
        }
    }
    cout << t.size();
    // set<pair <ll, ll> > ans;
    // ll sum = 0;
    // for(auto c: t){
    //     ll x = (c/b);
    //     x += c;
    //     x %= a;
    //     ll y= c%b;
    //     cout << c << " ";
    //     if(ans.count(make_pair(x,y))){
    //         cout << x << " " << y << " alr present\n";
    //     }
    //     else cout << x << " " << y << "\n";
    //     ans.insert(make_pair(x,y));
        
    //     sum ++;
    // }
    // cout << "\n";
    // // for(auto x: ans){
    // //     cout << x.first << " " << x.second << "\n";
    // // }
    // cout <<  ans.size();
    
    return 0;
}


int main(){
    fastio; 
    ll t = 1;
    // freopen("div7.in","r",stdin); 
    // freopen("div7.out","w",stdout);
    // cin >> t;
    for (int i = 0; i < t; ++i){
        // cout << "Case #" << i+1 << ": ";
        solve2();
        cout << "\n";
    }
    return 0;
}

Compilation message

strange_device.cpp: In function 'long long int solve2()':
strange_device.cpp:54:13: error: 'gcd' was not declared in this scope
   54 |     ll hc = gcd(q,z);
      |             ^~~