QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#657593 | #6423. Fireworks | LmR308 | AC ✓ | 296ms | 4016kb | C++17 | 1.4kb | 2024-10-19 15:02:34 | 2024-10-19 15:02:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int128 __int128_t
#define int long long
#define PII pair<int, int>
#define PDD pair<double, double>
#define fi first
#define se second
#define lowbit(x) x & -x
#define all(x) x.begin(), x.end()
#define INF 0x3f3f3f3f3f3f3f3f
#define ls(x) x << 1
#define rs(x) x << 1 | 1
#define ull unsigned long long
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e6 + 10, M = 5e6 + 10, mod = 998244353;
const double eps = 1e-8;
int t, n, m, k;
string sr;
void solve() {
int p;
cin >> n >> m >> p;
auto cal = [&](int x) {
int res = n * x + m;
long double temp = 1 - 1.0 * p / 10000;
long double te = 1 - pow(temp, x);
long double ans = 1.0 * res / te;
return ans;
};
if (p == 10000) {
cout << 1.0 * (n + m) << "\n";
return;
}
int l = 1, r = 1e9;
while (r > l) {
int mid1 = l + (r - l) / 3, mid2 = r - (r - l) / 3;
if (cal(mid1) < cal(mid2)) r = mid2 - 1;
else l = mid1 + 1;
}
long double res = 1.0;
long double temp = 1.0 - 1.0 * p / 10000;
res = 1.0 * (n * 1 + m) / (1 - temp);
temp = pow(temp, l);
res = min(res, 1.0 * (n * l + m) / (1 - temp));
cout << res << "\n";
}
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
cout.setf(ios::fixed), cout.precision(15);
t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3940kb
input:
3 1 1 5000 1 1 1 1 2 10000
output:
4.000000000000000 10141.585289114684959 3.000000000000000
result:
ok 3 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3988kb
input:
20 10 27 2855 79 59 6888 65 72 7725 78 50 2888 31 21 5759 41 58 6619 47 27 3881 35 55 5095 77 7 6028 17 89 1792 84 60 8604 58 44 4923 88 27 3824 54 63 1482 19 42 5366 93 76 97 100 99 8660 96 36 4343 90 56 9515 24 44 9922
output:
89.729805650548012 200.348432055749138 177.346278317152112 416.839877800354646 90.293453724604971 149.569421362743607 190.672507085802628 164.601521115576943 139.349701393497013 275.133110248422988 167.364016736401663 207.190737355271193 300.732217573221700 589.058848950519443 101.877028212448857 10...
result:
ok 20 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 4004kb
input:
10 954269343 987322500 9806 916720797 981711601 9728 902477101 957414437 9250 967013471 988735825 9674 985383693 926528961 9411 970653208 917703218 9331 998423148 911924940 9283 986159007 902133513 9759 953796828 947934512 9959 995334734 931874197 9944
output:
1980003919.029165762010962 1951513567.023026319686323 2010693554.594594498048536 2021655257.390944721759297 2031572260.121134739485569 2023744964.098167311167344 2057899480.771302349632606 1934924193.052566881757230 1909560538.206647239392623 1938062078.640386258717626
result:
ok 10 numbers
Test #4:
score: 0
Accepted
time: 1ms
memory: 4004kb
input:
10 933722894 72 9673 975866948 5 9424 910984544 95 9682 994597175 6 9351 972675086 51 9712 952759975 51 9114 956482031 85 9478 921988922 72 9017 950640658 36 9893 965297247 78 9342
output:
965287879.665046989568509 1035512471.349745314102620 940905431.728981664404273 1063626543.685167313669808 1001518880.766062652226537 1045380761.465876687085256 1009160282.760075991100166 1022500825.108129150758032 960922565.450318448536564 1033287652.536929959955160
result:
ok 10 numbers
Test #5:
score: 0
Accepted
time: 1ms
memory: 3944kb
input:
10 910088095 81 316 970640211 35 537 908853334 41 89 932269507 8 457 953224740 22 113 959834859 69 34 924852390 63 115 952730384 97 382 917634328 91 20 937287266 32 654
output:
28800258734.177250321954489 18075237355.679712153971195 102118356741.572815619409084 20399770568.927806505933404 84356173628.318757787346840 282304390588.238730698823929 80421952434.782925464212894 24940588507.853395486250520 458817209499.999592483043671 14331610061.162076513282955
result:
ok 10 numbers
Test #6:
score: 0
Accepted
time: 1ms
memory: 3928kb
input:
10 968675373 962412132 104 923494255 934310785 381 922721350 957856460 282 978335370 917228676 825 951116860 942542480 359 999013758 972493824 676 930242700 964474169 342 968944030 984608304 520 965837594 909045242 369 990484700 925952624 479
output:
106669104052.294624581933022 31076848077.761095166206360 40771434362.895142786204815 16579259543.363530134782195 33660076568.701911114156246 20209258011.501923045143485 34581380127.395100783556700 24798113234.332940859720111 33145494087.728251710534096 26925682159.120078910142183
result:
ok 10 numbers
Test #7:
score: 0
Accepted
time: 0ms
memory: 4000kb
input:
10 22 972733171 975 22 973609752 512 55 987399854 126 49 967364929 642 23 948126474 513 25 962813818 421 93 933323422 113 58 950364131 647 82 991906690 682 31 957667404 402
output:
972736672.681293441797607 973616306.986935916880611 987457697.396779324917588 967376069.315485323604662 948133283.101613932813052 962822722.647579097887501 933426898.317728195164818 950377057.363343162694946 991923706.585391661094036 957678776.965345430828165
result:
ok 10 numbers
Test #8:
score: 0
Accepted
time: 1ms
memory: 3700kb
input:
10 47 972371220 9743 65 949941115 9400 86 921812690 9736 11 927065494 9182 71 923766617 9378 63 941828720 9029 96 917539847 9084 88 952051332 9499 91 958386812 9427 64 950375055 9887
output:
972371465.901790268660989 949941549.320472925086506 921813131.821226126980036 927065583.858390120905824 923767096.493965991714504 941829231.442622725968249 917540568.647066358476877 952051875.055215206637513 958387391.921013795945328 950375326.495618894463405
result:
ok 10 numbers
Test #9:
score: 0
Accepted
time: 1ms
memory: 3936kb
input:
10 98 46 9403 99 89 9661 80 62 9450 25 20 9283 68 74 9328 54 14 9286 4 80 9574 35 61 9420 77 47 9943 22 9 9358
output:
153.142614059342759 194.596832626022159 150.264550264550272 48.475708283959926 152.229845626072047 73.228516045660135 87.737622728222266 101.910828025477713 124.710851855576793 33.126736482154308
result:
ok 10 numbers
Test #10:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
10 89 77 65 53 41 913 47 67 488 89 13 267 20 60 427 58 72 690 23 60 677 43 38 775 52 68 343 83 61 805
output:
15149.283838238704519 795.195959678695861 1340.262610317281884 3590.647504732409403 734.463107824570550 1204.044041798926167 568.432537046958705 761.453449761660061 1986.669558374136590 1378.158448339147587
result:
ok 10 numbers
Test #11:
score: 0
Accepted
time: 1ms
memory: 3932kb
input:
20 5 1000000000 4 3 999999979 5 5 1000000000 2 2 999999999 4 3 999999983 1 3 999999984 1 3 999999987 3 3 999999974 1 2 999999998 1 1 999999981 2 4 999999971 4 3 999999992 1 5 999999973 4 4 999999984 4 3 999999972 4 2 999999994 4 2 999999980 5 4 999999970 5 2 999999980 2 4 999999983 4
output:
1000153595.966846069728490 1000078103.937719044857658 1000289896.621388459112495 1000066017.486277998716105 1000342407.043464469665196 1000342408.043494458368514 1000125100.235101868456695 1000342398.043194571626373 1000236387.472664578526746 1000066005.589947742410004 1000125078.477628983033355 100...
result:
ok 20 numbers
Test #12:
score: 0
Accepted
time: 296ms
memory: 4016kb
input:
10000 15 999999991 6 16 999999975 2 12 999999978 9 7 999999993 4 19 999999980 5 20 999999977 5 13 999999995 10 11 999999979 6 19 999999995 5 6 999999982 10 15 999999978 1 2 999999974 5 12 999999980 4 18 999999997 1 12 999999992 10 20 999999970 6 2 999999999 2 13 999999984 1 16 999999984 2 16 9999999...
output:
1000289834.627433800254948 1000834644.980373640661128 1000162916.054420316533651 1000209141.238760390318930 1000424660.557301705935970 1000444958.758943629451096 1000159181.222366823116317 1000218214.149087710597087 1000424675.557871374068782 1000078088.897094844782259 1001470863.708315076655708 100...
result:
ok 10000 numbers
Test #13:
score: 0
Accepted
time: 2ms
memory: 4008kb
input:
50 3 999999983 9 8 999999973 7 6 999999988 9 17 999999995 10 19 999999993 6 13 999999989 6 17 999999995 1 8 999999999 7 9 999999971 3 15 999999986 8 2 1000000000 8 9 999999975 4 8 999999980 2 4 999999970 9 2 999999990 10 8 999999983 3 15 999999985 5 16 999999991 7 20 999999986 5 15 999999990 6 15 99...
output:
1000045336.023083025706001 1000141407.881453219510149 1000086075.416390764468815 1000203604.146658752055373 1000359647.071662342583295 1000254285.628474611090496 1001645751.815485733270179 1000141433.881750279804692 1000342363.795862711733207 1000222739.470001240551937 1000034735.235237658314873 100...
result:
ok 50 numbers