QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#506312 | #6423. Fireworks | ssmy | WA | 0ms | 4184kb | C++20 | 707b | 2024-08-05 16:35:53 | 2024-08-05 16:35:54 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> PII;
const double eps = 1e-7;
int m, n;
double p;
double check(double x)
{
return (x * n + m) / ((1 - pow(1 - p * 1e-4, x)));
}
void solve()
{
std:: cin >> m >> n >> p;
double l = 1, r = 1e6;
while((r - l) > eps)
{
double mid = (l + r) / 2;
if(check(mid - eps) < check(mid + eps))
{
r = mid;
}
else
{
l = mid;
}
}
std:: cout << fixed << setprecision(10) << min(check(ceil(l)), check(floor(l))) << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T;
std:: cin >> T;
while(T -- )
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4148kb
input:
3 1 1 5000 1 1 1 1 2 10000
output:
4.0000000000 10141.5852891147 3.0000000000
result:
ok 3 numbers
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 4184kb
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:
129.5971978984 200.3484320557 177.3462783172 356.0991190940 89.0092814611 149.5694213627 161.4505897494 176.6437684004 104.5517774990 591.5178571429 167.3640167364 196.7016872464 221.0800537029 636.1835568666 113.6787178531 9064.5777904316 229.7921478060 247.0648148512 153.4419337888 68.5345696432
result:
wrong answer 1st numbers differ - expected: '89.72981', found: '129.59720', error = '0.44430'