QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#635086#6423. FireworksrerebornzhouWA 0ms3864kbC++201.1kb2024-10-12 18:59:292024-10-12 18:59:29

Judging History

你现在查看的是最新测评结果

  • [2024-10-12 18:59:29]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3864kb
  • [2024-10-12 18:59:29]
  • 提交

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