My Weblog

Blog about programming and math

SPOJ Problem ROOTCIPH

This problem is kind of cryptic in first reading but reading carefully reveals that it simply asking about (x_1^2+x_2^2+x_3^2) where x_1,x_2,x_3 is root of cubic equation. [roots are the coordinates of the aircraft relative to the radar.]. a=-(x_1+x_2+x_3), b=x_1*x_2+x_2*x_3+x_1*x_3 , c=-(x_1*x_2*x_3) .

#include<cstdio>
#include<iostream>
using namespace std;


int main()
    {
		int t;
		long long a,b,c;
		for(scanf("%d",&t);t>0;t--)
		{
			scanf("%lld%lld%lld",&a,&b,&c);
			cout<<a*a-2*b<<endl;
		
		}
    }
Advertisements

December 6, 2010 - Posted by | Programming

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: