Uva 12704 – Little Masters

  /*
Uva 12704 – Little Masters.
Verdict : Accepted
Time: 0.000
Use the radius equation r = sqrt (x*x + y*y) ; and then compare with the given radius. The subtraction result will be the shortest and addition result will be the longest distance.
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <sstream>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#define sf scanf
#define pf printf
#define sfint scanf (“%d %d”,&a,&b)
#define sfl scanf (“%ld %ld”,&a,&b)
#define sfll scanf (“%lld %lld”,&a,&b)
#define sfd scanf (“%lf %lf”,&a,&b)
#define sff scanf (“%f %f”,&a,&b)
#define loop (i,n) for (i=0;i<n;i++)
#define LL long long
#define L long
#define nl puts(“”)
#define N 10000
#define MOD 10000000007
#define pb push_back
#define pi acos(-1.0)
#define sz size()
#define gc getchar ()
#define ps push
#define clr clear
#define bn begin()
#define ed end()
using namespace std;
int main()
{
int x,y,r,t;
sf (“%d”,&t);
while (t–)
{
sf (“%d %d %d”,&x,&y,&r);
float final_radius = sqrt((x*x) + (y*y));
float shortest_distance = abs(final_radius – r);
float longest_distance = final_radius + r;
printf(“%0.2f %0.2f\n”,shortest_distance, longest_distance);
}
return 0;
}

Comments

Popular posts from this blog

SPOJ-CMG - Collecting Mango

LightOJ 1009 - Back to Underworld

LeetCode Palindrome Number