need help in a problem

Правка en1, от raj_aman, 2019-08-02 10:35:32

problem big money can anyone find out the error in my solution,i have worked on all boundary cases: /* ID: Aman Raj LANG: C++ TASK: prefix */ //#include

include <stdio.h>

//#include

include

include

using namespace std;

include<math.h>

typedef long long int ll;

include <bits/stdc++.h>

include

include

include

include

include

include

include

include

include

include

include

include

include

include <ext/pb_ds/assoc_container.hpp>

include <ext/pb_ds/tree_policy.hpp>

//setbase — cout << setbase (16); cout << 100 << endl; Prints 64 //setfill — cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77 //setprecision — cout << setprecision (14) << f << endl; Prints x.xxxx //cout.precision(x) cout<<fixed<<val; // prints x digits after decimal in val

using namespace std; using namespace __gnu_pbds;

define f(i,a,b) for(i=a;i<b;i++)

define rep(i,n) f(i,0,n)

define fd(i,a,b) for(i=a;i>=b;i--)

define pb push_back

define mp make_pair

define vi vector< int >

define vl vector< ll >

define ss second

define ff first

//#define ll long long

define pii pair< int,int >

define pll pair< ll,ll >

define sz(a) a.size()

define inf (1000*1000*1000+5)

define all(a) a.begin(),a.end()

define tri pair<int,pii>

define vii vector

define vll vector

define viii vector

define mod (1000*1000*1000+7)

//#define mod 13

define pqueue priority_queue< int >

define pdqueue priority_queue< int,vi ,greater< int > >

//#define flush fflush(stdout)

define primeDEN 727999983

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

include

// find_by_order() // order_of_key typedef tree< int, null_type, less, rb_tree_tag, tree_order_statistics_node_update> ordered_set; ll power(ll a,ll b)//a raised to power b { if(b==0)return 1;if(b==1)return a; ll c=power(a,b/2); c*=c;c%=mod;if(b%2==1)c*=a;c%=mod; return c; } ll mi(ll a) { return power(a,mod-2); }

double l1,r1,p1,l2,r2,p2;

int main() { ll m;cin>>m; ll n;cin>>n; while(n--) { cin>>l1>>r1>>p1>>l2>>r2>>p2; double ans=0.0+m;

if(m>=l1&&m<=r1)
        {
            double ans2=m+p1*m/100;
            if(ans2-ans>0.000000000)ans=ans2;
        }
        if(m>=l2&&m<=r2)
        {
            double ans2=m+p2*m/100;
            if(ans2-ans>0.000000000)ans=ans2;
        }
        ll a=l1,b=m-l1;
        if(a>=0&&b>=0)
        {  double ans2;
            if(b>=l2&&b<=r2)
            {  ans2=a+b+p1*a/100+p2*b/100;


            }
            else ans2=a+b+p1*a/100;
            if(ans2-ans>0.000000000)ans=ans2;
        }
         a=r1,b=m-r1;
        if(a>=0&&b>=0)
        {  double ans2;
            if(b>=l2&&b<=r2)
            {  ans2=a+b+p1*a/100+p2*b/100;


            }
            else ans2=a+b+p1*a/100;
            if(ans2-ans>0.000000000)ans=ans2;
        }

         a=r2,b=m-r2;
        if(a>=0&&b>=0)
        {  double ans2;
            if(b>=l1&&b<=r1)
            {  ans2=a+b+p1*b/100+p2*a/100;


            }
            else ans2=a+b+p2*a/100;
            if(ans2-ans>0.000000000)ans=ans2;
        }

         a=l2,b=m-l2;
        if(a>=0&&b>=0)
        {  double ans2;
            if(b>=l1&&b<=r1)
            {  ans2=a+b+p2*a/100+p1*b/100;


            }
            else ans2=a+b+p2*a/100;
            if(ans2-ans>0.000000000)ans=ans2;
        }


       //cout<<setprecision(100000000)<<fixed;
       cout<<setprecision(12)<<fixed;
       cout<<ans<<endl;



   }


return 0;

}

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский raj_aman 2019-08-02 12:17:14 39
en2 Английский raj_aman 2019-08-02 10:37:20 2137
en1 Английский raj_aman 2019-08-02 10:35:32 4158 Initial revision (published)