## 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

No comments yet.

## Leave a Reply