UVa 11346 - Probability Solution

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        double a,b,s;
        cin>>a>>b>>s;
        if(s==0)
            cout<<"100.000000%"<<endl;
        else if(a*b<=s)
            cout<<"0.000000%"<<endl;
        else{
            double area=s*log(a*b/s)+s;
            cout<<fixed<<setprecision(6)<<round(1e8*(1-area/(a*b)))/1e6<<'%'<<endl;
        }
    }
}

Comments