QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#578101#6423. Fireworkslibantian#Compile Error//C++23821b2024-09-20 16:37:242024-09-20 16:37:25

Judging History

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

  • [2024-09-20 16:37:25]
  • 评测
  • [2024-09-20 16:37:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define double long double
#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;
    }
    double t=f(l);
    double t=min(t,f(l+1));
    cout<<t<<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;
}

Details

answer.code: In function ‘void solve()’:
answer.code:27:12: error: redeclaration of ‘long double t’
   27 |     double t=min(t,f(l+1));
      |            ^
answer.code:26:12: note: ‘long double t’ previously declared here
   26 |     double t=f(l);
      |            ^