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

http://www.codechef.com/problems/CAKE1AM

$
0
0

I cant figure out why my code is not being accepted. It is giving me wrong output.The link to question is http://www.codechef.com/problems/CAKE1AM. My code is -

include <iostream>

include <math.h>

include <stdlib.h>

using namespace std;

int main() { int t; int a[5]; int b[5]; int c[3];

cin>>t;
while(t--)
{
    for(int i = 0; i < 4; i++)
    {
        cin>>a[i];
    }
    for(int i = 0; i < 4; i++)
    {
        cin>>b[i];
    }
    if((a[2]<b[0]) && (a[3]<b[1]))
    {
        c[0]=abs((a[2]-a[0]) *(a[1]-a[3]));
        c[1] =abs((b[0]-b[2])*(b[1]-b[3]));

    }
    else  
    {
            c[0]=abs((a[2]-a[0]) *(a[1]-a[3]));
            c[1] =abs((b[0]-b[2])*(b[1]-b[3]) ) - abs((a[2]-b[0])*(a[3]-b[1]));  
    }
    cout<<c[0]+c[1]<<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>