QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#162252#7110. Kuririn MIRACLEucup-team1198#Compile Error//C++202.1kb2023-09-03 06:59:362023-09-03 06:59:37

Judging History

你现在查看的是最新测评结果

  • [2023-09-03 06:59:37]
  • 评测
  • [2023-09-03 06:59:36]
  • 提交

answer

#include <bits/stdc++.h>

#pragma GCC optimize("fast-math")

using namespace std;
#define ll long long
#define pii pair<int, int>
#define ld long double
#define all(a) (a).begin(), (a).end()

const ld pi = atan2l(1, 0) * 2;
const int T = 10000000;


ld get_dphi(ld phi, ld u, ld r) {
    ld sinp = sinl(phi);
    return (- u * sinp + sqrtl(u * u * (sinp * sinp + 3))) / (2 * r);
}

ld tphi[T + 2];

void precalc() {
    ld cur_t = 0;
    for (int i = 0; i < T; ++i) {
        ld phi = pi * i / T;
    
        ld dphi = get_dphi(phi, 1, 1);  // at further point better
        cur_t += pi / T / dphi;
        tphi[i + 1] = cur_t;
    }
}

ld get(ld phi, ld v, ld r) {
    ld prop = phi / pi * T;
    int i = floor(prop);

    return r / v * (tphi[i] * (1 - (prop - i)) + tphi[i + 1] * (prop - i));
}

long double rush(ld phi, ld r, ld v, ld d, ld t) {
    d -= 2 * r + t * v;

    ld x = - 2 * r * cosl(phi);
    ld y = 2 * r * sinl(phi);

    ld x1 = d - x;
    ld y1 = y;

    ld l = sqrtl(x1 * x1 + y1 * y1);
    ld fac = 2 * v / l;

    x1 *= fac;
    y1 *= fac;

    x1 -= v;

    if (x1 * x > y * y1 - 1e-7) {
        // cerr << l << '\n';
        return l / (2 * v);
    } else {
        return -1;
    }
}

void solve() {
    ld u, r, d;
    
    u = 2.0;
    r = 3;
    d = 30;

    cin >> u >> r >> d;

    if (get(pi, u, r) * u <= d - 4 * r) {
        ld lp = pi / 2;
        ld rp = pi;

        for (int i = 0; i < 300; ++i) {
            ld mp = (lp + rp) / 2;

            ld t = get(mp, u, r);
            if (rush(mp, r, u, d, t) >= 0) {
                rp = mp;
            } else {
                lp = mp;
            }
        }

        ld t = get(rp, u, r);
        cout << t + max(0L, rush(rp, r, u, d, t)) << '\n';

    } else {
        cout << d / u << '\n';        
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    precalc();


    // for (int i = 0; i < T; ++i) {
    //     presin[i] = sinl(pi * i / T);
    //     precos[i] = cosl(pi * i / T);
    //     pre3sin[i] = presin[i] * presin[i] + 3;
    // }

    cout << fixed << setprecision(15);

    int t = 1000;
    cin >> t;
    while (t--) solve();


    return 0;
}

詳細信息

answer.code: In function ‘void solve()’:
answer.code:90:24: error: no matching function for call to ‘max(long int, long double)’
   90 |         cout << t + max(0L, rush(rp, r, u, d, t)) << '\n';
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
answer.code:90:24: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long double’)
   90 |         cout << t + max(0L, rush(rp, r, u, d, t)) << '\n';
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
answer.code:90:24: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long double’)
   90 |         cout << t + max(0L, rush(rp, r, u, d, t)) << '\n';
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)’
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
answer.code:90:24: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long int’
   90 |         cout << t + max(0L, rush(rp, r, u, d, t)) << '\n';
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)’
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
answer.code:90:24: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long int’
   90 |         cout << t + max(0L, rush(rp, r, u, d, t)) << '\n';
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~