답안 #962024

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
962024 2024-04-13T04:29:51 Z Amr 이상한 기계 (APIO19_strange_device) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define S second
#define F first
#define all(x) (x).begin(),(x).end()
#define sz size()
#define Yes cout << "YES" << endl
#define No cout << "NO" << endl
#define pb(x) push_back(x);
#define endl '\n'
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int N=3e5+7;
ll INF=INT_MAX,mod=1e9+7;
int TT=1;
ll power(ll x, unsigned int y)
{
    ll res = 1;
    x = x; // % mod;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1) res = (res*x)  ; // % mod;
        y = y>>1;
        x = (x*x) ; // % mod;
    }
    return res;
}
typedef unsigned long long ull;
ll lo(ll x)
{
    ll cnt = 0;
    while(x) cnt++,x/=10;
    return cnt-1;
}
ll f(ll x, ll y)
{
    ll m = (x/power(10,lo(x)))*(y/power(10,lo(y)));
    return (lo(x)+lo(y)+lo(m)>=19||(x*y)>1e18);
}
pair<ll,ll> a[N];
void solve()
{
    ll n;
    ull a , b;
    cin >> n >> a >> b;
    ll mgcd = __gcd(a,b+1);
    a/=mgcd;
    ll cntans = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> arr[i].F >> arr[i].S;
        cntans+= arr[i].S-arr[i].F+1;
    }
    if(f(a,b))
    {
        cout << cntans << endl; return;
    }
    else cout << min(cntans,a*b) << endl;
}
int main(){
    //freopen("friday.in","r",stdin);
    //freopen("friday.out","w",stdout);
    fast;
    while(TT--)
        solve();

    return 0;
}

Compilation message

strange_device.cpp: In function 'void solve()':
strange_device.cpp:53:16: error: 'arr' was not declared in this scope
   53 |         cin >> arr[i].F >> arr[i].S;
      |                ^~~
strange_device.cpp:60:32: error: no matching function for call to 'min(ll&, ull)'
   60 |     else cout << min(cntans,a*b) << endl;
      |                                ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from strange_device.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
strange_device.cpp:60:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'ull' {aka 'long long unsigned int'})
   60 |     else cout << min(cntans,a*b) << endl;
      |                                ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from strange_device.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
strange_device.cpp:60:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'ull' {aka 'long long unsigned int'})
   60 |     else cout << min(cntans,a*b) << endl;
      |                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from strange_device.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
strange_device.cpp:60:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   60 |     else cout << min(cntans,a*b) << endl;
      |                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from strange_device.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
strange_device.cpp:60:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   60 |     else cout << min(cntans,a*b) << endl;
      |                                ^