Submission #649783

# Submission time Handle Problem Language Result Execution time Memory
649783 2022-10-11T10:53:22 Z ToroTN Strange Device (APIO19_strange_device) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define X first
#define Y second
#define pb push_back
ll n,a,b,x,y,md,cnt=0,mx=-1,l,r,di;
set<pair<ll,ll> > s;
vector<pair<ll,ll> > v;
ll gcdprajao(ll a,ll b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
int main()
{
    scanf("%lld%lld%lld",&n,&a,&b);
    di=a/gcdprajao(b+1,a);
    if(di>(1e18+1)/b)
    {
        md=1e18+1;
    }else
    {
        md=di*b;
    }
    //printf("%lld\n",md);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld%lld",&x,&y);
        x%=md;
        y%=md;
        if(x<=y)
        {
            v.pb({x,y});
        }else
        {
            v.pb({x,md-1});
            v.pb({0,y});
        }
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++)
    {
        l=v[i].X;
        r=v[i].Y;
        if(l>mx)
        {
            cnt+=(r-l+1);
            mx=r;
        }else
        {
            if(r>mx)
            {
                cnt+=r-mx;
                mx=r;
            }
        }
    }
    printf("%lld\n",cnt);
}

Compilation message

strange_device.cpp: In function 'long long int gcdprajao(long long int, long long int)':
strange_device.cpp:13:12: error: 'gcd' was not declared in this scope
   13 |     return gcd(b,a%b);
      |            ^~~
strange_device.cpp: In function 'int main()':
strange_device.cpp:42:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
strange_device.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf("%lld%lld%lld",&n,&a,&b);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf("%lld%lld",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~