QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#195337 | #5151. Bottle Flip | kevinshan# | AC ✓ | 1ms | 3812kb | C++20 | 1.6kb | 2023-10-01 03:33:44 | 2023-10-01 03:33:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define ps push
#define in insert
#define f first
#define s second
#define nl cout<<"\n"
#define ca(v) for(auto i:v) cout<<i<<" ";
#define cbit(x) __builtin_popcount(x)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a*b/gcd(a, b))
int xm[4] = {-1, 1, 0, 0};
int ym[4] = {0, 0, -1, 1};
const int MOD = 1e9 + 7;
const int MAXN = 5e5 + 5;
const ll POW = 9973;
#define ld long double
pair<ld, ld> eval(ld m, ld h, ld a, ld w){
// cout<<m*m*w + (h*h-m*m) * a <<" "<<w * m + a * (h - m)<<"\n";
return {((m*m*w) + ((h*h-m*m) * a)), (w * m + a * (h - m))};
// return ((m*m*w) + ((h*h-m*m) * a)) / (w * m + a * (h - m));
}
// bool comp(pair<ll,ll> a, pair<ll,ll> b){
// return a.f * b.s <= b.f * a.s;
// }
bool comp(pair<ld,ld> a, pair<ld,ld> b){
return a.f * b.s <= b.f * a.s;
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
ld h, R, a, w;
cin>>h>>R>>a>>w;
// h *= 10000000;
ld l = 0;
ld r = h;
while(r - l > 1e-7){
ld diff = (r-l)/3;
ld m = l + diff;
ld mp1 = l + 2*diff;
// cout << "Z"<< m << " " << mp1<<endl;
// cout<<m<<" "<<mp1<<"\n";
// cout<<eval(m, h, a, w)<< " "<<eval(mp1, h, a, w)<<"\n";
if(comp(eval(m, h, a, w), eval(mp1, h, a, w))){
// l = m;
r=mp1;
}
else{
// cout<<"E";
// r = mp1;
l=m;
}
}
cout << setprecision(9);
cout<<l<<endl;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3700kb
input:
22 4 1 4
output:
7.3333333
result:
ok found '7.3333333', expected '7.3333333', error '0.0000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3688kb
input:
7 2 655 988
output:
3.14159413
result:
ok found '3.1415941', expected '3.1415942', error '0.0000000'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
1 1 1 2
output:
0.414213519
result:
ok found '0.4142135', expected '0.4142136', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
1000 1000 999 1000
output:
499.874932
result:
ok found '499.8749320', expected '499.8749375', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
1000 1000 1 1000
output:
30.65343
result:
ok found '30.6534300', expected '30.6534300', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
1 1000 1 1000
output:
0.0306533691
result:
ok found '0.0306534', expected '0.0306534', error '0.0000001'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3700kb
input:
1000 1000 482 483
output:
499.740934
result:
ok found '499.7409340', expected '499.7409326', error '0.0000000'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3692kb
input:
1 1000 482 483
output:
0.499740893
result:
ok found '0.4997409', expected '0.4997409', error '0.0000000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
1 1000 1 2
output:
0.414213519
result:
ok found '0.4142135', expected '0.4142136', error '0.0000000'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
1000 1000 1 2
output:
414.213562
result:
ok found '414.2135620', expected '414.2135624', error '0.0000000'
Test #11:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
961 1000 979 983
output:
480.010192
result:
ok found '480.0101920', expected '480.0101932', error '0.0000000'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
997 1000 977 983
output:
497.736987
result:
ok found '497.7369870', expected '497.7369880', error '0.0000000'
Test #13:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
1 928 1 66
output:
0.10960053
result:
ok found '0.1096005', expected '0.1096006', error '0.0000001'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
1 928 2 88
output:
0.131005747
result:
ok found '0.1310057', expected '0.1310058', error '0.0000001'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
1 928 3 74
output:
0.167600881
result:
ok found '0.1676009', expected '0.1676009', error '0.0000000'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
1 928 3 41
output:
0.212908826
result:
ok found '0.2129088', expected '0.2129089', error '0.0000000'
Test #17:
score: 0
Accepted
time: 1ms
memory: 3748kb
input:
1 928 1 12
output:
0.224009204
result:
ok found '0.2240092', expected '0.2240092', error '0.0000000'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
2 928 89 93
output:
0.989009616
result:
ok found '0.9890096', expected '0.9890097', error '0.0000000'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
7 928 51 72
output:
3.19900983
result:
ok found '3.1990098', expected '3.1990099', error '0.0000000'
Test #20:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
722 547 709 752
output:
355.686391
result:
ok found '355.6863910', expected '355.6863918', error '0.0000000'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
242 742 518 920
output:
103.742903
result:
ok found '103.7429030', expected '103.7429035', error '0.0000000'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
873 701 43 201
output:
276.087556
result:
ok found '276.0875560', expected '276.0875558', error '0.0000000'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
268 228 527 562
output:
131.846092
result:
ok found '131.8460920', expected '131.8460919', error '0.0000000'
Test #24:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
312 558 341 839
output:
121.468385
result:
ok found '121.4683850', expected '121.4683851', error '0.0000000'
Test #25:
score: 0
Accepted
time: 1ms
memory: 3688kb
input:
274 85 178 364
output:
112.756491
result:
ok found '112.7564910', expected '112.7564907', error '0.0000000'
Test #26:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
641 539 341 977
output:
238.054439
result:
ok found '238.0544390', expected '238.0544387', error '0.0000000'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
245 861 438 872
output:
101.618384
result:
ok found '101.6183840', expected '101.6183839', error '0.0000000'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
640 181 156 606
output:
215.419835
result:
ok found '215.4198350', expected '215.4198349', error '0.0000000'