QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#268662#6423. Fireworksyujie3WA 1ms4208kbC++20804b2023-11-28 19:31:452023-11-28 19:31:45

Judging History

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

  • [2023-11-28 19:31:45]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4208kb
  • [2023-11-28 19:31:45]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5 + 7;
const double esp = 1e-7;
int n,m,k;
int a[N],b[N];
double p;

double check(double x){
    return (x * n + m) / (1 - pow(1 - p,x));
}

void solve(){
    cin >> n >> m;
    cin >> p;
    p /= 1e4;
    double l = 1,r = 1e9;
    while(r - l > esp){
        double cnt = (r - l) / 3.0;
        double mid1 = l + cnt;
        double mid2 = r - cnt;
        if(check(mid1) < check(mid2)){
            r = mid2;
        } else{
            l = mid1;
        }
    } double ans = check(l);
    printf("%.10lf\n",ans);
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int _; cin >> _;
    while(_ --){
        solve();
    } return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 4208kb

input:

3
1 1 5000
1 1 1
1 2 10000

output:

3.8640379203
10141.5852631479
3.0000000000

result:

wrong answer 1st numbers differ - expected: '4.00000', found: '3.86404', error = '0.03399'