Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

[Guidance] What's the method to get precision till decimal place defined by user ?

$
0
0

I am working on this problem LMA1

I tried this method from the editorial. Why am I getting WA ?

#include<bits/stdc++.h>
using namespace std;

int main(){
ios::sync_with_stdio(0);
double t,a,n,p,d,q;
cin>>t;
while(t--){
    cin>>a>>p>>q>>d;
    cout<<setprecision(d)<<(p*a*(1-a)+(q*a))/((1-a)*(1-a))<<endl;

}

return 0;
}

Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>