QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#162079#5677. Clarissa's Conical Cannolis1e11AC ✓1ms3780kbC++203.5kb2023-09-03 03:56:492023-09-03 03:56:50

Judging History

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

  • [2023-09-03 03:56:50]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3780kb
  • [2023-09-03 03:56:49]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/priority_queue.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
/* ordered_set notes:
    .order_of_key(k): Number of items strictly smaller than k
    .find_by_order(k): k-th element in a set
*/
#define X first
#define Y second
template <typename A, typename B> istream& operator >> (istream& o, pair<A, B> &a) {
    return o >> a.X >> a.Y;
}
template <typename A, typename B> ostream& operator << (ostream& o, pair<A, B> a) {
    return o << '(' << a.X << ", " << a.Y << ')';
}
#ifdef cychien
#define DE(...) do {\
	fprintf(stderr, "%s - %d : (%s) = ", __PRETTY_FUNCTION__, __LINE__, #__VA_ARGS__);\
    _DO(__VA_ARGS__);\
}while(0) 
template<typename I> void _DO(I&&x) {cerr << x << '\n';}
template<typename I, typename ...T> void _DO(I&&x,T&&...tail) {cerr << x << ", "; _DO(tail...);}
template<class T> void debug(T l, T r) { while (l != r) cerr << *l << " \n"[next(l)==r], ++l; }
#define IOS
#else
#define DE(...)
#define debug(...)  
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#endif
#define W(v) {for(auto it = (v).begin(); it != (v).end(); it++)cout << *it << " \n"[next(it) == (v).end()];}
#define pb emplace_back
#define mp make_pair
#define rsz resize
#define SZ(x) (ll)x.size()
#define AI(x) (x).begin(),(x).end()
#define SORT(x) sort(AI(x))
template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); }
template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); }
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
const int NF = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int Rand(){
    return uniform_int_distribution<int>(INT_MIN, INT_MAX)(rng);
}
/*
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using mint = modint998244353;
*/
using dbl = long double;
const dbl eps = 1e-8, PI = acos(-1);
dbl D, S, r, o;
dbl theta;
dbl up(dbl x){
    return x * x;
}
dbl crepe(dbl B, dbl m){
    dbl a = r, b = S - B - m, c = S - B - r;
    DE(a, S, B, m, b, c);
    dbl phi = acos((b * b + c * c - a * a) / 2 / b / c);
    dbl arc = 2 * b * phi;
    return arc;
}
dbl cone(dbl B){
    return (S - B) / S * PI * D;
}
int main() {
    IOS;
    cin >> D >> S >> r >> o;

    theta = acos(D / 2 / S);
    auto chk = [&](dbl B){
        dbl lo = 0, hi = 2 * r;
        while (hi - lo > eps){
            dbl ml = (lo + lo + hi) / 3, mr = (lo + hi + hi) / 3;
            dbl lhs = crepe(B, ml) - cone(B + ml), rhs = crepe(B, mr) - cone(B + mr);

            if (lhs < rhs){
                lo = ml;
            }
            else {
                hi = mr;
            }
        }
        DE(B, lo, crepe(B, lo));
        return crepe(B, lo) - cone(B + lo);
    };

    cerr << fixed << setprecision(20);
    if (chk(S - 2 * r) < o - eps){
        cout << "-2.0\n";
    }
    else if (chk(0) > o + eps){
        cout << "-1.0\n";
    }
    else {
        dbl lo = 0, hi = S - 2 * r;
        while (hi - lo > eps){
            dbl mid = (hi + lo) / 2;
            if (chk(mid) < o) lo = mid;
            else hi = mid;
        }
        cout << fixed << setprecision(1) << lo << '\n';
    }
    return 0;
}


詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3712kb

input:

8.00 12.00 5.00 0.50

output:

1.5

result:

ok single line: '1.5'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3648kb

input:

5.00 12.00 5.00 0.50

output:

-1.0

result:

ok single line: '-1.0'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3552kb

input:

11.00 12.00 5.00 0.50

output:

-2.0

result:

ok single line: '-2.0'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3772kb

input:

7.00 12.00 3.00 0.90

output:

5.8

result:

ok single line: '5.8'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

8.50 12.00 3.00 0.90

output:

-2.0

result:

ok single line: '-2.0'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

10.00 12.00 3.00 0.70

output:

-2.0

result:

ok single line: '-2.0'

Test #7:

score: 0
Accepted
time: 1ms
memory: 3780kb

input:

5.50 12.00 3.50 0.30

output:

3.4

result:

ok single line: '3.4'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3756kb

input:

7.00 12.00 3.50 0.70

output:

4.5

result:

ok single line: '4.5'

Test #9:

score: 0
Accepted
time: 1ms
memory: 3732kb

input:

8.50 12.00 3.50 0.70

output:

5.0

result:

ok single line: '5.0'

Test #10:

score: 0
Accepted
time: 1ms
memory: 3676kb

input:

10.00 12.00 3.50 0.30

output:

-2.0

result:

ok single line: '-2.0'

Test #11:

score: 0
Accepted
time: 1ms
memory: 3684kb

input:

5.50 12.00 4.00 0.70

output:

2.5

result:

ok single line: '2.5'

Test #12:

score: 0
Accepted
time: 1ms
memory: 3676kb

input:

7.00 12.00 4.00 0.90

output:

3.5

result:

ok single line: '3.5'

Test #13:

score: 0
Accepted
time: 1ms
memory: 3736kb

input:

8.50 12.00 4.00 0.50

output:

3.8

result:

ok single line: '3.8'

Test #14:

score: 0
Accepted
time: 1ms
memory: 3604kb

input:

10.00 12.00 4.00 0.30

output:

-2.0

result:

ok single line: '-2.0'

Test #15:

score: 0
Accepted
time: 1ms
memory: 3776kb

input:

5.50 12.00 4.50 0.50

output:

1.1

result:

ok single line: '1.1'

Test #16:

score: 0
Accepted
time: 1ms
memory: 3732kb

input:

7.00 12.00 4.50 0.50

output:

2.1

result:

ok single line: '2.1'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

8.50 12.00 4.50 0.70

output:

2.9

result:

ok single line: '2.9'

Test #18:

score: 0
Accepted
time: 1ms
memory: 3600kb

input:

10.00 12.00 4.50 0.50

output:

-2.0

result:

ok single line: '-2.0'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3676kb

input:

5.50 12.00 5.00 0.30

output:

-1.0

result:

ok single line: '-1.0'

Test #20:

score: 0
Accepted
time: 1ms
memory: 3668kb

input:

7.00 12.00 5.00 0.90

output:

1.3

result:

ok single line: '1.3'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

8.50 12.00 5.00 0.70

output:

1.8

result:

ok single line: '1.8'

Test #22:

score: 0
Accepted
time: 1ms
memory: 3776kb

input:

10.00 12.00 5.00 0.30

output:

2.0

result:

ok single line: '2.0'

Test #23:

score: 0
Accepted
time: 1ms
memory: 3704kb

input:

5.50 12.00 5.50 0.90

output:

-1.0

result:

ok single line: '-1.0'