QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#635086 | #6423. Fireworks | rerebornzhou | WA | 0ms | 3864kb | C++20 | 1.1kb | 2024-10-12 18:59:29 | 2024-10-12 18:59:29 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define int long long
#define ull unsigned long long
#define fi first
#define se second
#define pi pair<int,int>
const int N=1e6+10;
const int INF=1e18;
const double eps=1e-8;
double qp(double a,int b){
double ans=1;
while(b){
if(b&1) ans=ans*a;
b>>=1;
a=a*a;
}
return ans;
}
void solve(){
int n,m;
double p;
cin>>n>>m>>p;
p/=10000;
double l=1,r=1e10;
auto f = [&](int x){
double P=qp((1-p),x);
return (double)(n*x+m)+(double)(n*x+m)*P/(1-P);
};
// cout<<f(1)<<"\n";
while(r-l>2){
int mid1=l+(r-l)/3;
int mid2=r-(r-l)/3;
if(f(mid1)>f(mid2)) l=mid1;
else r=mid2;
}
double ans=1e18;
for(int i=l;i<=r;i++){
ans=min(ans,f(i));
}
printf("%.6.lf\n",ans);
// cout<<ans<<"\n";
}
signed main(){
IOS
int _=1;
cin>>_;
while(_--){
solve();
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3864kb
input:
3 1 1 5000 1 1 1 1 2 10000
output:
%.6.lf %.6.lf %.6.lf
result:
wrong output format Expected double, but "%.6.lf" found