QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#578502 | #6423. Fireworks | libantian | WA | 0ms | 4160kb | C++23 | 747b | 2024-09-20 19:36:21 | 2024-09-20 19:36:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define fi first
#define se second
#define all(_a) _a.begin(),_a.end()
const double eps=1e-9;
double n,m;
double p;
double f(int x){
return ((n*x+m)*1.0)/(1.0-pow(1.0-p,x));
}
void solve(){
cin>>n>>m>>p;
p*=0.0001;
double l=0.0,r=1e9;
while(r-l>eps){
double m1=l+(r-l)/3;
double m2=r-(r-l)/3;
if(f(m1)>f(m2)) l=m1;
else r=m2;
}
cout<<f(l)<<endl;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr),cin.tie(nullptr);
cout << setiosflags(ios::fixed) << setprecision(15);
int T=1;
cin>>T;
while(T--)solve();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 4160kb
input:
3 1 1 5000 1 1 1 1 2 10000
output:
inf 10141.589499295954738 inf
result:
wrong output format Expected double, but "inf" found