QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#619844 | #6423. Fireworks | xDarkbluex# | TL | 1ms | 4228kb | C++17 | 859b | 2024-10-07 15:37:18 | 2024-10-07 15:37:18 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
int T;
double n,m,p;
double qpow(double a,int x)
{
double ans=1;
while(x)
{
if(x&1)
{
ans=(ans*a);
}
a=(a*a);
x>>=1;
}
return ans;
}
int check(double x)
{
double py=-n/(x*log(p)),y=log(py)/log(p);
double y1=floor(y),y2=ceil(y);
if(y1>=1&&y1*n+m+x*(qpow(p,(int)y1)-1)<=0)
{
return 1;
}
if(y2>=1&&y2*n+m+x*(qpow(p,(int)y2)-1)<=0)
{
return 1;
}
if(n+m+x*(p-1)<=0)
{
return 1;
}
return 0;
}
void solve()
{
scanf("%lf%lf%lf",&n,&m,&p);
p=1-p/10000;
double l=0,r=1e18+7;
while(r-l>1e-8)
{
double mid=(l+r)/2.0;
if(check(mid))
{
r=mid;
}
else
{
l=mid;
}
}
double ans=(l+r)/2.0;
printf("%.12lf\n",ans);
}
signed main()
{
cin>>T;
while(T--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4228kb
input:
3 1 1 5000 1 1 1 1 2 10000
output:
3.999999999078 10141.585289118993 2.999999998501
result:
ok 3 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 4172kb
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.729805650460 200.348432057479 177.346278317918 416.839877800448 90.293453725372 149.569421361381 190.672507088678 164.601521115374 139.349701395539 275.133110247097 167.364016735093 207.190737354341 300.732217572435 589.058848951160 101.877028212775 10796.887266901609 229.792147807267 303.9373704...
result:
ok 20 numbers
Test #3:
score: -100
Time Limit Exceeded
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