Help me in solving BIGSALE problem

My issue

how to increase the precision

My code

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

int main() {
    int t;
    cin>>t;
    while(t--){
        float loss;
        int n;
        cin>>n;
        loss = 0.000000000;
        for(int i=0; i<n; i++){
            float p, q, d;
            cin>>p>>q>>d;
            loss+=q*p*(1.000000000-(1.000000000+(d/100))*(1.000000000-(d/100)));
            
        }
        cout<<loss<<endl;
    }
	// your code goes here

}

Problem Link: A Big Sale Practice Coding Problem

cout<<fixed<<setprecision(6)<<loss<<endl;

1 Like

Hey, Thanks for that.

I tried this too, but it’s giving me the same answer without precision.

By the way, I tried this approach, and it works pretty well, check it out.

 #include <bits/stdc++.h>
using namespace std;
 
int main() {
     int t;
     cin >> t;
     while(t--) {
         double loss = 0;
         int n;
         cin >> n;
         for(int i = 0; i < n; i++) {
             double p, q, d;
             cin >> p >> q >> d;
             double offer = (d * p) / 100;
             double inc = p + offer;
             double discount = (d * inc) / 100;
             double final = inc - discount;
             loss += q * (p - final);
         }
         cout <<fixed<<setprecision(9)<< loss << endl;
     }
    
 
     return 0;
 }