11437 - Triangle Fun

All about problems in Volume 114. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
Sabiha_Fancy
New poster
Posts: 24
Joined: Mon Jul 16, 2012 3:43 pm

11437 - Triangle Fun

Post by Sabiha_Fancy »

I am getting wrong answer. help me.
here is my code:

Code: Select all

removed after ac
Fancy
pralgomathic
New poster
Posts: 1
Joined: Wed Mar 26, 2014 5:59 pm

11437 - Triangle Fun

Post by pralgomathic »

can anyone please tell where I have made the mistakes, it's getting me WA! :( Please help .thanks

Code: Select all

#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
    double ax,ay,bx,by,cx,cy;

    int n;
    while(cin>>n)
    {
        for(int i=0;i<n;i++)
        {
            cin>>ax>>ay>>bx>>by>>cx>>cy;
            long double a,b,c;
            long double area;
            a = ax*(by-cy);
            b = bx*(cy-ay);
            c = cx*(ay-by);
            area = abs((a+b+c)/2);
            //long long  res = (long long)(area/7);
            //cout<<res<<endl;
            cout<<floor(area/7)<<endl;
        }


    }

    return 0;


}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11437 - Triangle Fun

Post by brianfry713 »

Only read N once.
In my AC code I used only double, no long doubles.
Check input and AC output for thousands of problems on uDebug!
Post Reply

Return to “Volume 114 (11400-11499)”