Circle of death CodeChef Solution

Problem -Circle of death CodeChef Solution

This website is dedicated for CodeChef solution where we will publish right solution of all your favourite CodeChef problems along with detailed explanatory of different competitive programming concepts and languages.

Circle of death CodeChef Solution in C++14

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#ifdef ONLINE_JUDGE
    #define endl "\n"
#endif

#define gcd(a,b) __gcd(a,b)
#define all(cont) conbegin(), conend()
#define rall(cont) conend(), conbegin()
#define rsort(x) sort(x,[](auto a, auto b){rtn a > b;});
#define forr(i,v) for (int i = 0; i < v; i++)
#define each(x,v) for (auto x: v)
#define forrr(i,j,v,w) for (int i = 0; i < v; i++) for (int j = 0; j < w; j++)
#define ni(x) int x; cin >> x;
#define nii(x,y) int x,y; cin >> x >> y;
#define niii(x,y,z) int x,y,z; cin >> x >> y >> z;
#define niiii(w,x,y,z) int w,x,y,z; cin >> w >> x >> y >> z;
#define nl(x) ll x; cin >> x;
#define nll(x,y) ll x,y; cin >> x >> y;
#define nlll(x,y,z) ll x,y,z; cin >> x >> y >> z;
#define nllll(w,x,y,z) ll w,x,y,z; cin >> w >> x >> y >> z;
#define get(v) vi v;forr (i,n){ni(x);v.pb(x);}
#define amax(a,b) a = max(a,b);
#define amin(a,b) a = min(a,b);
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rz resize
#define sz size()
#define cnt continue
#define brk break
#define rtn return
#define W() int T; cin >> T; while(T--)
#define trace(x) cerr<<#x<<": "<<x<<endl;
#define output()
#define ff first
#define float double
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
typedef long long ll;
typedef string str;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<str> vs;
typedef vector<pii> vpii;
typedef vector<vpii> vppii;
typedef vector<vi> vii;
typedef unordered_map<int,int> mpii;
typedef set<int> seti;
typedef set<pair<int,int>> spii;
typedef vector<set<int>> vseti;

const ll linf = 1e18+10;
const int inf = 1e9+10;
const double eps = 1e-9;
const double pi = 3.1415926535897932384626433832795;
const int mod = 1000000007;
const int base = 31;

ll max(ll a, ll b){
    return a > b ? a : b;
}

ll min(ll a, ll b){
    return a < b ? a : b;
}

void out(vl v){
    for (int i:v){
        cerr << i << " ";
    }
    cerr << endl;
}

void out(vi v){
    for (int i:v){
        cerr << i << " ";
    }
    cerr << endl;
}

void out(vb v){
    for (int i:v){
        cerr << i << " ";
    }
    cerr << endl;
}

void out(vii v){
    for (vi i:v){
        out(i);
    }
    cerr << endl;
}

void out(pii i){
    cerr << "<" << i.ff << "," << i.ss << ">  ";
}

void out(vpii v){
    for (pii i:v){
        out(i);
    }
    cerr << endl;
}

void out(mpii v){
    for (pii i:v){
        out(i);
    }
    cerr << endl;
}

void out(int v[], int n){
    forr (i,n){
        cerr << v[i] << " ";
    }
    cerr << endl;
}

void out(map<int,int> v){
    for (pii i:v){
        out(i);
    }
    cerr << endl;
}

int add(int a, int b){
    int res = (a+b) % mod;
    if (res < 0)
        res += mod;
    rtn res;
}

int mul(int a, int b){
    int res = (a * 1LL * b) % mod;
    if (res < 0)
        res += mod;
    rtn res;
}

int power(int a, int b){
    int res = 1;
    while(b){
        if (b % 2)
            res = mul(res,a);
        a = mul(a,a);
        b /= 2;
        
    }
    rtn res;
}

int inv(int x){
    rtn x == 1 ? 1 : power(x,mod-2);
}

void ans (str x){
    cout << x << endl;
}

void ans (const char* x){
    cout << x << endl;
}

template<typename T>
void ans (T x){
    ans(to_string(x));
}

bool isPrime(int x)
{
    int primes[168] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997};
    int j = 0;
    while (primes[j] < floor(sqrt(x)) + 1)
    {
        if (x % primes[j] == 0)
        {
            return false;
        }
        j++;
    }
    return true;
}

void sieve(int n=1000005){
    bool p[1000005];
    memset(p,1,sizeof(p));
    p[0] = p[1] = 0;
    for (int i = 2; i * i < n; i++){
        if (p[i]){
            for (int j = 2 * i; j < n; j += i){
                p[j] = 0;
            }
        }
    }
}

vi range(int n){
    vi v(n);
    for (int i = 1;i < n; i++){
        v[i] = i;
    }
    rtn v;
}

#define x ff
#define y ss
typedef pair<double,double> pdd;

double cross(pii a, pii b){
    rtn a.x * 1.0 * b.y - a.y * 1.0 * b.x;
}

double area(pii a, pii b, pii c){
    rtn abs(cross({b.x - a.x,b.y - a.y},{c.x - b.x,c.y - b.y})/2.0);
}

double radius(pii a, pii b, pii c){
    auto d = area(a,b,c);
    if (d == 0) rtn 0.0;
    rtn hypot(a.x - b.x, a.y - b.y) * hypot(c.x - b.x, c.y - b.y) * hypot(a.x - c.x, a.y - c.y) / (4.0 * d);
}

double dist(pii a, pii b){
    rtn hypot(a.x - b.x,a.y - b.y);
}

pdd centre(pii a, pii b, pii c)
{
	rtn {a.x - ((((b.y-a.y)*dist(c,a)*dist(c,a)) -  ((c.y-a.y)*dist(b,a)*dist(b,a)))/(2.0*((b.x-a.x)*(c.y-a.y)  - (c.x-a.x)*(b.y-a.y))))
	,a.y + (((b.x-a.x)*(dist(c,a)*dist(c,a)) - (c.x-a.x)*(dist(b,a)*dist(b,a)))/(2.0* (((b.x-a.x)*(c.y-a.y))-((c.x-a.x)*(b.y-a.y)))))};
}

void pre(){
    
}

void solve(){
    ni(n);
    vpii v;
    forr (i,n){
        nii(x,y);
        v.pb({x,y});
    }
    int t = 0, b = 0;
    forr (i,n){
        forr (j,i){
            forr (k,j){
                pdd c;
                auto r = radius(v[i],v[j],v[k]);
                if (r < eps){
                    c = {0,0};
                } else {
                    c = centre(v[i],v[j],v[k]);
                }
                // cerr << c.ff << " " << c.ss << " " << r << endl;
                forr (m,n){
                    if (m == i || m == j || m == k) cnt;
                    b ++;
                    if (r == 0){
                        cnt;
                    }
                    t += hypot(c.x-v[m].x,c.y-v[m].y) <= (r + eps);
                    if (0 && hypot(c.x-v[m].x,c.y-v[m].y) <= (r + eps)){
                        out(v[i]);
                        out(v[j]);
                        out(v[k]);
                        cerr << "<" << c.ff << "," << c.ss << ">  ";
                        out(v[m]);
                        cerr << endl;
                    }
                }
            }
        }
    }
    ans(t * 1.0 / b);
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
    
    #ifndef ONLINE_JUDGE
        freopen("../../input.txt","r",stdin);
        freopen("../../output.txt","w",stdout);
        freopen("../../error.txt","w",stderr);
    #endif
    clock_t tStart = clock();
    
    pre();
    W(){
        solve();
    }

    double t =  (double)(clock() - tStart)/CLOCKS_PER_SEC;
    cerr << endl << "Time: " << t;
	rtn 0;
}

/*


*/

Circle of death CodeChef Solution in PYTH 3

# cook your dish here
# cook your dish here

from itertools import combinations
T = int(input())
while T != 0:
	N = int(input())
	points = []
	for i in range(N):
		x,y = map(int,input().strip().split())
		points.append([x,y])
	kill = 0
	total = (N*(N-1)*(N-2)*(N-3))/6
	comb = combinations(points,3)
	for x in list(comb):
		[x1,y1] = x[0]
		[x2,y2] = x[1]
		[x3,y3] = x[2]
		area = (x1 - x2)*(y2 - y3) - (y1 - y2)*(x2 - x3)
		if area == 0:
			continue
		x12 = x1 - x2
		x13 = x1 - x3
		y12 = y1 - y2
		y13 = y1 - y3
		y31 = y3 - y1
		y21 = y2 - y1
		x31 = x3 - x1
		x21 = x2 - x1
		sx13 = pow(x1, 2) - pow(x3, 2)
		sy13 = pow(y1, 2) - pow(y3, 2)
		sx21 = pow(x2, 2) - pow(x1, 2)
		sy21 = pow(y2, 2) - pow(y1, 2)
		f = (((sx13) * (x12) + (sy13) * (x12) + (sx21) * (x13) + (sy21) * (x13)) / (2 * ((y31) * (x12) - (y21) * (x13))))
		g = (((sx13) * (y12) + (sy13) * (y12) + (sx21) * (y13) + (sy21) * (y13)) / (2 * ((x31) * (y12) - (x21) * (y13))))
		c = (-pow(x1, 2) - pow(y1, 2) - 2 * g * x1 - 2 * f * y1)
		for i in points:
			if i in x:
				continue
			else:
				if (pow(i[0],2) + pow(i[1],2) + 2*g*i[0] + 2*f*i[1] + c) <= 0.000001:
					kill = kill+1
	prob = kill/total
	print(prob)
	T = T-1

Circle of death CodeChef Solution in C

#include<stdio.h>
#include<math.h>
#define MAX  31
struct point
{
	int x;
	int y;
};
int det(int a1,int a2,int a3,int b1,int b2,int b3,int c1,int c2,int c3)
{
	return a1*(b2*c3-b3*c2)-a2*(b1*c3-b3*c1)+a3*(b1*c2-b2*c1);
}
main()
{
	int test,area=0,n,count,com,i,j,k,l,c1,c2,c3,c4,d;
	struct point a[MAX];
	scanf("%d",&test);
	while(test--)
	{
		scanf("%d",&n);
		count=0;com=0,area=0;
		for(i=0;i<n;i++)
		{
			scanf("%d %d",&a[i].x,&a[i].y);
		}
		
for(i=0;i<n;i++)
{
	for(j=i+1;j<n;j++)
	{
		for(k=j+1;k<n;k++)
		{
			com+=(n-3);
					 
					 area=det(a[i].x,a[i].y,1,a[j].x,a[j].y,1,a[k].x,a[k].y,1);
					if(area==0)
					{
					
						//printf("Line ");
						continue;
					}
					else
					{
						c1=area;
						c2=det(pow(a[i].x,2)+pow(a[i].y,2),a[i].y,1,
							   pow(a[j].x,2)+pow(a[j].y,2),a[j].y,1,
							   pow(a[k].x,2)+pow(a[k].y,2),a[k].y,1);
						c3=det(pow(a[i].x,2)+pow(a[i].y,2),a[i].x,1,
							   pow(a[j].x,2)+pow(a[j].y,2),a[j].x,1,
							   pow(a[k].x,2)+pow(a[k].y,2),a[k].x,1);						
						c4=det(pow(a[i].x,2)+pow(a[i].y,2),a[i].x,a[i].y,
							   pow(a[j].x,2)+pow(a[j].y,2),a[j].x,a[j].y,
							   pow(a[k].x,2)+pow(a[k].y,2),a[k].x,a[k].y);
						//printf("\n equ is %d %d %d %d",c1,c2,c3,c4);
						for(l=0;l<n;l++)
						{
								if(l==i || l==j || l==k)
									continue;
								
					
								d=c1*(pow(a[l].x,2)+pow(a[l].y,2))-c2*a[l].x+c3*a[l].y-c4;
								if(area>0 && d<=0)
									count++;
								else if(area<0 && d>=0)
									count++;
						}
						
						
					}
					
				}
			}
		}
		//printf("%d is com and %d is count",com,count);
		printf("%.6lf\n",(double)count/(double)com);
	}
}

Circle of death CodeChef Solution in JAVA

/* package codechef; // don't place package name! */

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
public class Point {
int x ;
int y ;
public Point(int xx , int yy) {
x = xx;
y = yy;
}
}
 
static Main main;
 
public static void main(String [] args ) {
main = new Main();
try{
String str;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedOutputStream bos = new BufferedOutputStream(System.out);
String eol = System.getProperty("line.separator");
byte [] eolb = eol.getBytes();
str = br.readLine();
int t = Integer.parseInt(str);
for(int i = 0 ; i < t ; i++) {
str = br.readLine();
int n = Integer.parseInt(str);
Point [] points = new Point[n];
for(int j = 0 ; j < n ; j++) {
str = br.readLine();
int blank = str.indexOf( " ");
int x = Integer.parseInt(str.substring(0,blank));
int y = Integer.parseInt(str.substring(blank+1));
points[j] = main.new Point(x,y);
}
int count = 0;
int countT = 0;
for(int p = 0 ; p < n ; p++) {
for(int q = p+1 ; q < n ; q++) {
for(int r = q+1 ; r < n ; r++) {
countT+=(n-3);
if(!collinear(points[p],points[q],points[r])) {
for(int s = 0 ; s < n ; s++) {
if((s!=p)&&(s!=q)&&(s!=r)) {
// find circumradius and circumcentre;
long x = points[s].x;
long y = points[s].y;
long x1 = points[p].x;
long y1 = points[p].y;
long x2 = points[q].x;
long y2 = points[q].y;
long x3 = points[r].x;
long y3 = points[r].y;
long a = (x1*(y2-y3)-y1*(x2-x3)+x2*y3-x3*y2) ;
long bx = ((x1*x1+y1*y1)*(y2-y3)-y1*(x2*x2+y2*y2-x3*x3-y3*y3)+(x2*x2+y2*y2)*y3-(x3*x3+y3*y3)*y2);
bx *= -1;
long by = ( (x1*x1+y1*y1)*(x2-x3) - x1*(x2*x2+y2*y2-x3*x3-y3*y3) + (x2*x2+y2*y2)*x3 - (x3*x3+y3*y3)*x2);
long c = (x1*x1+y1*y1)*(x2*y3-x3*y2) - x1*((x2*x2+y2*y2)*y3-(x3*x3+y3*y3)*y2) + y1 *((x2*x2+y2*y2)*x3-(x3*x3+y3*y3)*x2) ;
c*=-1;
long x0 = 2 * a * x + bx ;
long y0 = 2 * a * y + by ;
x0*=x0;
y0*=y0;
long r0 = bx*bx+by*by-4*a*c;
if((x0+y0)<=r0) {	
count++;
}
}
}
}
}
}
}
double prob = ((double)count)/((double)(countT));
bos.write(new Double(prob).toString().getBytes());
bos.write(eolb);
}
bos.flush();
} catch(IOException ioe) {
ioe.printStackTrace();
}
}
public static boolean collinear(Point p1 , Point p2 , Point p3 ) {
int x1 = p1.x;
int y1 = p1.y;
int x2 = p2.x;
int y2 = p2.y;
int x3 = p3.x;
int y3 = p3.y;
if(((y2-y1)*(x3-x1))==((y3-y1)*(x2-x1)) ) {
return true;
}
return false;
}
}

Circle of death CodeChef Solution in PYTH

import math

x,y =[],[]

def ss(i):
	return x[i] * x[i] + y[i] * y[i] 
def check(a,b,c):
	s2 = [ss(a),ss(b),ss(c)]
	D =  (x[a] * (y[b]-y[c]) + x[b] * ( y[c]-y[a]) + x[c] *(y[a]-y[b]))
	if D == 0:return [0,0,-1]
	sx = (ss(a)* (y[b]-y[c]) + ss(b) * ( y[c]-y[a]) + ss(c)*(y[a]-y[b]))*0.5 / D
	sy = (ss(a)* (x[b]-x[c]) + ss(b) * ( x[c]-x[a]) + ss(c)*(x[a]-x[b]))*-0.5/ D
	r  = math.hypot(x[a]-sx,y[a]-sy)
	return [sx,sy,r]
def solve():
	global x,y
	n = int(raw_input())
	x ,y= [0] * n ,[0] *n
	num,den = 0,0
	for i in xrange(n):
		x[i],y[i] = map(int,raw_input().split())
	for a in xrange(n):
		for b in xrange(a+1,n):
			for c in xrange(b+1,n):
				sx,sy,r= check(a,b,c)
				#print [(x[a],y[a]),(x[b],y[b]),(x[c],y[c])],r,(sx,sy)
				for i in xrange(n):
					if a!=i and b!=i and c!=i:
						if math.hypot(x[i]-sx,y[i]-sy) < r + 1e-9:
							num+=1
						den +=1
	print num * 1. / den

for i in xrange(int(raw_input())):
	solve()

Circle of death CodeChef Solution in C#

#define ONLINE_JUDGE

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

class Program
{

    static int tests = 1;

#if (ONLINE_JUDGE)
    static TextReader r = Console.In;
    static TextWriter w = Console.Out;
#else
    static string path = @"C:\Y\Prog\CodeChef\2013-06-Circle-of-death\";
    static string answerFile = "0{0}Answer.txt";
    static string resultFile = "0{0}Result.txt";
    static string sourceFile = "0{0}Source.txt";
    
    static TextReader r;
    static TextWriter w;
#endif

    static void Main(string[] args)
    {

        //Point p = Line.getCenter(new Point(98,100), new Point(100, 102), new Point(102,100));
        //Console.WriteLine("Point {0} {1}", p.x, p.y);
        //return;

        for (int i = 1; i <= tests; i++)
        {
#if (!ONLINE_JUDGE)
            r = new StreamReader(string.Format(path + sourceFile, i));
            w = new StreamWriter(string.Format(path + resultFile, i), false);
#endif
            int cases = Convert.ToInt32(r.ReadLine());
            for (int j = 0; j < cases; j++)
                solve();
#if (!ONLINE_JUDGE)
            w.Flush(); w.Close();
            Console.WriteLine("CASE: {0}", i);
            string answer = File.ReadAllText(string.Format(path + answerFile, i));
            string result = File.ReadAllText(string.Format(path + resultFile, i));
            if (answer != result)
            {
                Console.WriteLine("FAIL:");
                Console.WriteLine("Result" + Environment.NewLine + result);
                Console.WriteLine("Answer" + Environment.NewLine + answer);
            }
            else
                Console.WriteLine("OK");
#endif
        }
    }

    public static void solve()
    {
        int n = Convert.ToInt32(r.ReadLine());
        Point[] points = new Point[n];
        for (int i = 0; i < n; i++)
        {
            string[] buff = r.ReadLine().Split(' ');
            points[i] = new Point(Convert.ToInt32(buff[0]), Convert.ToInt32(buff[1]));
        }

        int totalKilled = 0;
        int cases = 0;
        //Console.WriteLine("begin"); 
        for (int i1 = 0; i1 < points.Length; i1++)
            for (int i2 = i1+1; i2 < points.Length; i2++)
                for (int i3 = i2+1; i3 < points.Length; i3++)
                {
                    if (i1 == i2 || i1 == i3 || i2 == i3) continue;
                    cases++;
                    Point p = Line.getCenter(points[i1], points[i2], points[i3]);
                    if (p.x == double.NaN) continue;
                    double r1 = p.dist(points[i1]);

                    //if (i1 == 0 && i2 == 1 && i3 == 4)
                    //{
                    //    Console.Write("A ");                    
                    //}
                    for (int i4 = 0; i4 < points.Length; i4++)
                    {
                        if (i4 == i1 || i4 == i2 || i4 == i3) continue;
                        double r2 = p.dist(points[i4]);
                        if (r2 < (r1 + 1e-06))
                        {
                            totalKilled++;
                            //Console.Write("Killed ");
                            //Console.WriteLine("p1 {0} p2 {1} p3 {2} p4 {3} r2 {4} r1 {5}", i1, i2, i3, i4, r2, r1);
                        }
                        else
                        {
                            //Console.Write("Fail ");
                            //Console.WriteLine("p1 {0} p2 {1} p3 {2} p4 {3} r2 {4} r1 {5}", i1, i2, i3, i4, r2, r1);                       
                        }
                    }                    
                }
        w.WriteLine((totalKilled / (double) cases) / (points.Length - 3.0)); 
    }
        
    public static void getLineIntersection()
    { 
    
    }

}

public class Line
{
    // ax + by = c
        
    public double a;
    public double b;
    public double c;
    public Line(Point p1, Point p2)
    {
        a = p2.y - p1.y;
        b = p1.x - p2.x;
        c = a * p1.x - b * p1.y;
    }

    public Line(double a, double b, double c) { this.a = a; this.b = b; this.c = c; }
    
    public static Point getIntersection(Line l1, Line l2)
    {
        Point p = new Point(double.NaN, double.NaN);
        double det = l1.a * l2.b - l2.a * l1.b;
        if (Math.Abs(det) < 1e-09) return p;
        p.x = (l2.b * l1.c - l1.b * l2.c) / det;
        p.y = (l1.a * l2.c - l2.a * l1.c) / det;
        return p;
    }

    public static Line getPerp(Point p1, Point p2)
    {
        Line l = new Line(p1, p2);
        Point center = new Point((p1.x + p2.x) / 2, (p1.y + p2.y) / 2);
        double a = -l.b;
        double b = l.a;
        double c = a * center.x + b * center.y;
        return new Line(a, b, c);
    }

    public static Point getCenter(Point p1, Point p2, Point p3)
    {
        return getIntersection(getPerp(p1, p2), getPerp(p2, p3));
    }

}

public class Point
{
    public double x, y;
    public Point(double x, double y) { this.x = x; this.y = y; }
    public double dist(Point p) { return Math.Sqrt( (p.x - x) * (p.x - x) + (p.y - y) * (p.y - y)); } 
}

Circle of death CodeChef Solution in GO

package main

import (
	"fmt"
)

func IntAbs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func one_case() {
	//fmt.Println("case investigation started")
	pn := 0
	fmt.Scan(&pn)
	arx, ary := make([]int, pn), make([]int, pn)
	for p := 0; p < pn; p++ {
		fmt.Scan(&arx[p], &ary[p])
	}

	var num, denum float64 //probability
	for p := 0; p < pn; p++ {
		for q := p+1; q < pn; q++ {
			for r := q+1; r < pn; r++ {
				x1, y1 := arx[p], ary[p]
				x2, y2 := arx[q], ary[q]
				x3, y3 := arx[r], ary[r]
				
				denxy := 2 * ((y3-y2)*(x2-x1) - (x3-x2)*(y2-y1))

				numx := (x2*x2 - x1*x1 + y2*y2 - y1*y1) * (y3-y2) - 
					(x3*x3 - x2*x2 + y3*y3 - y2*y2) * (y2-y1)

				numy := (x2-x1) * (x3*x3 - x2*x2 + y3*y3 - y2*y2) - 
					(x3-x2) * (x2*x2 - x1*x1 + y2*y2 - y1*y1)

				if denxy < 0 {
					denxy, numx, numy = -denxy, -numx, -numy
				}

				//fmt.Println("\tp1 = ", x1, ",", y1)
				//fmt.Println("\tp2 = ", x2, ",", y2)
				//fmt.Println("\tp3 = ", x3, ",", y3)
				//if denxy == 0 {
				//	fmt.Println("\tno circle")
				//} else {
				//	fmt.Println("\t circle center = ", float64(numx) / float64(denxy),
				//		float64(numy) / float64(denxy))
				//}

				for s:=0; s < pn; s++ {
					if s != p && s != q && s != r {
						x,y := arx[s], ary[s]
						//fmt.Print("\t\tcand = ", x, ",", y)
						if denxy!=0 && 
							(x-x1)*((x+x1)*denxy - 2*numx) + 
							(y-y1)*((y+y1)*denxy - 2*numy) <= 0 {
							//fmt.Println(" accepted")
							num++
						}// else {
						//	fmt.Println(" declined")
						//}
						denum++
					}
				}
				//fmt.Println()
			}
		}
	}
	fmt.Println(num/denum)
}

func main() {
	tk := 0
	fmt.Scan(&tk)
	for t := 0; t < tk; t++ {
		one_case()
	}
}
Circle of death CodeChef Solution Review:

In our experience, we suggest you solve this Circle of death CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Circle of death CodeChef Solution.

Find on CodeChef

Conclusion:

I hope this Circle of death CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Programming Language in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

Cognitive Class Answer

CodeChef Solution

Microsoft Learn

Leave a Reply

Your email address will not be published. Required fields are marked *