QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#506577 | #6423. Fireworks | mmzskm | WA | 1ms | 4032kb | C++20 | 747b | 2024-08-05 19:43:21 | 2024-08-05 19:43:22 |
Judging History
answer
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;
int n, m;
long double p;
long double f(int x)
{
long double pp = 1.0 - (long double)pow(1.0 - p, x);
int t = n * x + m;
return (long double)t / pp;
}
void solve()
{
cin >> n >> m >> p;
p /= 10000;
int l = 1, r = 0x3f3f3f3f;
while (l < r)
{
int mid1 = l + (r - l) / 3;
int mid2 = r - (r - l) / 3;
if (f(mid1) < f(mid2))
{
r = mid2 - 1;
}
else
{
l = mid1 + 1;
}
}
cout << fixed << setprecision(12) << f(l) << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T;
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: 3924kb
input:
3 1 1 5000 1 1 1 1 2 10000
output:
4.000000000000 10141.585289113577 3.000000000000
result:
ok 3 numbers
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 4032kb
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:
-2147483645.000000000000 -2147483611.000000000000 -2147483611.000000000000 -2147483622.000000000000 -2147483633.000000000000 -2147483613.000000000000 -2147483644.000000000000 -2147483647.000000000000 -2147483618.000000000000 -2147483639.000000000000 -2147483584.000000000000 -2147483608.000000000000 ...
result:
wrong answer 1st numbers differ - expected: '89.72981', found: '-2147483645.00000', error = '23932780.40849'