Random number generator

There is an ideal random number generator, which given a positive integer M can generate any real number between 0 to M, and probability density function is uniform in [0, M].

Given two numbers A and B and we generate x and y using the random number generator with uniform probability density function [0, A] and [0, B] respectively,  what's the probability that x + y is less than C? where C is a positive integer.

Input Format

The first line of the input is an integer N, the number of test cases.

N lines follow. Each line contains 3 positive integers A, B and C.

Constraints

All the integers are no larger than 10000.

Output Format

For each output, output a fraction that indicates the probability. The greatest common divisor of each pair of numerator and denominator should be 1.

Sample Input

3
1 1 1
1 1 2
1 1 3

Sample Output

1/2
1/1
1/1

Source: hackerrank | Difficulty: EASY
Tags: Probability


Solutions:
from itertools import product
from fractions import Fraction
for t in range(int(input())):
	tmp = input().split()
	(A, B, C) = [int(i) for i in tmp]
	if A + B <= C:
		fr = Fraction(1, 1)
	elif C <= A and C <= B:
		fr = Fraction(C ** 2, 2 * A * B)
	elif C <= B:
		fr = Fraction(2 * C * A - A ** 2, 2 * A * B)
	elif C <= A:
		fr = Fraction(2 * C * B - B ** 2, 2 * A * B)
	else:
		fr = Fraction(2 * C * (A + B) - A ** 2 - B ** 2 - C ** 2, 2 * A * B)
	print(fr.numerator, '/', fr.denominator, sep='')


from fractions import Fraction
from sys import stdin
(k,) = [int(n) for n in stdin.readline().split()]
for i in range(k):
	line = stdin.readline()
	(_a, _b, c) = [int(x) for x in line.split()]
	a = min(_a, _b)
	b = max(_a, _b)
	if c < a:
		print(Fraction(c * c, 2 * a * b))
	elif c < b:
		print(Fraction(2 * c - a, 2 * b))
	elif c < a + b:
		print(Fraction(2 * a * b - (a - c + b) ** 2, 2 * a * b))
	else:
		print('1/1')


import fractions

def D():
	(A, B, C) = input().split(' ')
	A = int(A)
	B = int(B)
	C = int(C)
	if A > B:
		(A, B) = (B, A)
	ans = 0
	S = A * B * 2
	if C < A:
		ans = fractions.Fraction(C * C, S)
	elif C < B:
		ans = fractions.Fraction(2 * A * C - A * A, S)
	elif C >= A + B:
		ans = 1
	else:
		ans = fractions.Fraction(C * C - (C - A) ** 2 - (C - B) ** 2, S)
	if ans >= 1:
		print('1/1')
	else:
		print(ans)
t = int(input())
while t > 0:
	t -= 1
	D()


def simplify(a, b):
	F = [a, b]
	if a > b:
		(a, b) = (b, a)
	while a > 0:
		(a, b) = (b % a, a)
	F = [F[0] // b, F[1] // b]
	return F
N = int(input())
for n in range(0, N):
	(A, B, C) = [int(x) for x in input().strip().split(' ')]
	if A > B:
		(A, B) = (B, A)
	if C <= 0:
		print('{}/{}'.format(0, 1))
		continue
	if C >= A + B:
		print('{}/{}'.format(1, 1))
		continue
	if C <= A:
		F = simplify(C * C, 2 * A * B)
		print('{}/{}'.format(F[0], F[1]))
		continue
	if C >= B:
		F = simplify(2 * A * B - (A + B - C) * (A + B - C), 2 * A * B)
		print('{}/{}'.format(F[0], F[1]))
		continue
	F = simplify(2 * A * C - A * A, 2 * A * B)
	print('{}/{}'.format(F[0], F[1]))
	continue


import sys

def gcd(a, b):
	return b and gcd(b, a % b) or a
T = int(sys.stdin.readline())
for _ in range(T):
	(A, B, C) = [int(x) for x in sys.stdin.readline().split()]
	(A, B) = (min(A, B), max(A, B))
	domain = 2 * A * B
	if C >= A + B:
		print('1/1')
	else:
		if C <= A:
			cover = C * C
		elif A < C <= B:
			cover = 2 * A * (C - A) + A ** 2
		else:
			cover = 2 * A * (C - A) + 2 * (A + B - C) * (C - B) + (A + B - C) ** 2
		n = gcd(cover, domain)
		print('%d/%d' % (cover // n, domain // n))


import sys
from fractions import Fraction
next(sys.stdin)
for line in sys.stdin:
	(A, B, C) = map(int, line.strip().split())
	(A, B) = sorted((A, B))
	if A + B <= C:
		print('1/1')
	elif B <= C:
		result = Fraction(C ** 2 - (C - A) ** 2 - (C - B) ** 2, 2 * A * B)
		print('{}/{}'.format(result.numerator, result.denominator))
	elif A <= C:
		result = Fraction(C ** 2 - (C - A) ** 2, 2 * A * B)
		print('{}/{}'.format(result.numerator, result.denominator))
	else:
		result = Fraction(C ** 2, 2 * A * B)
		print('{}/{}'.format(result.numerator, result.denominator))


from fractions import Fraction

def compute_probability(A, B, C):
	a1 = C ** 2
	a2 = (C - A) ** 2 if A < C else 0
	a3 = (C - B) ** 2 if B < C else 0
	a4 = (C - A - B) ** 2 if A + B < C else 0
	return Fraction(a1 - a2 - a3 + a4, 2 * A * B)
N = int(input())
for i in range(N):
	(A, B, C) = map(int, input().split())
	result = compute_probability(A, B, C)
	if result == 1:
		print(str(result) + '/1')
	else:
		print(result)


from fractions import Fraction as f
for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a + b <= c:
		print('1/1')
	else:
		(a, b) = sorted((a, b))
		if a > c:
			print(f(c * c, 2 * a * b))
		elif b <= c:
			print(1 - f((a + b - c) ** 2, 2 * a * b))
		else:
			print(1 - f((2 * (b - c) + a) * a, 2 * a * b))


from fractions import *
for n in range(int(input())):
	(a, b, c) = [int(i) for i in input().split()]
	if a >= c and b >= c:
		a_ = Fraction(c, a)
		b_ = Fraction(c, b)
		sq = a_ * b_ / 2
		print(sq.numerator, sq.denominator, sep='/')
	elif a >= c and b < c:
		a1 = Fraction(c, a)
		a2 = Fraction(c - b, a)
		sq = (a1 + a2) / 2
		print(sq.numerator, sq.denominator, sep='/')
	elif a < c and b >= c:
		b1 = Fraction(c, b)
		b2 = Fraction(c - a, b)
		sq = (b1 + b2) / 2
		print(sq.numerator, sq.denominator, sep='/')
	elif a + b <= c:
		print('1/1')
	else:
		a_ = 1 - Fraction(c - a, b)
		b_ = 1 - Fraction(c - b, a)
		sq = 1 - a_ * b_ / 2
		print(sq.numerator, sq.denominator, sep='/')


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
tests = int(input())
for t in range(tests):
	(a, b, c) = input().strip().split()
	(a, b, c) = (int(a), int(b), int(c))
	(small, large) = (0, 0)
	if a < b:
		small = a
		large = b
	else:
		small = b
		large = a
	(num, denom) = (0, 1)
	if c > 0 and c <= small:
		num = c ** 2
		denom = 2 * large * small
	elif c > small and c <= large:
		num = 2 * c - small
		denom = 2 * large
	elif c > large and c <= small + large:
		num = -(small ** 2 + (large - c) ** 2 - 2 * small * c)
		denom = 2 * small * large
	elif c > small + large:
		(num, denom) = (1, 1)
	gcd_int = gcd(num, denom)
	print(str(num // gcd_int) + '/' + str(denom // gcd_int))


from fractions import gcd

def rng_probability(a, b, c):
	if a > b:
		return rng_probability(b, a, c)
	if a + b <= c:
		return (1, 1)
	d = 2 * a * b
	if c <= a:
		n = c ** 2
	elif a < c <= b:
		n = 2 * a * (c - a) + a ** 2
	else:
		n = 2 * a * (c - a) + (a + b - c) ** 2 + 2 * (a + b - c) * (c - b)
	g = gcd(n, d)
	return (n // g, d // g)
for i in range(int(input())):
	(a, b, c) = map(int, input().split(' '))
	print('%d/%d' % rng_probability(a, b, c))


import fractions as fr
for i in range(int(input())):
	lst = [int(i) for i in input().split(' ')]
	a = lst[0]
	b = lst[1]
	c = lst[2]
	denominator = a * b * 2
	numerator = 0
	if a > b:
		(a, b) = (b, a)
	if c < a:
		numerator += c ** 2
	elif c < b:
		numerator += a ** 2
		numerator += (c - a) * a * 2
	elif c < a + b:
		numerator += a ** 2
		numerator += (b - a) * a * 2
		numerator += a ** 2
		numerator -= (a + b - c) ** 2
	else:
		numerator = 2 * a * b
	res = str(fr.Fraction(numerator, denominator))
	if '/' in res:
		print(res)
	else:
		print(res + '/1')


import sys

def gcd(a, b):
	return b and gcd(b, a % b) or a
T = int(sys.stdin.readline())
for _ in range(T):
	(A, B, C) = [int(x) for x in sys.stdin.readline().split()]
	(A, B) = (min(A, B), max(A, B))
	domain = 2 * A * B
	if C >= A + B:
		print('1/1')
	else:
		if C <= A:
			cover = C * C
		elif A < C <= B:
			cover = 2 * A * (C - A) + A ** 2
		else:
			cover = 2 * A * (C - A) + 2 * (A + B - C) * (C - B) + (A + B - C) ** 2
		n = gcd(cover, domain)
		print('%d/%d' % (cover // n, domain // n))


from fractions import Fraction
for _ in range(int(input())):
	(a, b, c) = map(int, input().split(' '))
	upper = min((a, c))
	lower = max((0, c - b))
	if lower < upper:
		rez = Fraction((upper - lower) * c, a * b) - Fraction(upper ** 2 - lower ** 2, 2 * a * b)
	else:
		rez = Fraction(0, 1)
	if c - b > 0:
		rez += min((Fraction(c - b, a), Fraction(1, 1)))
	print(rez.numerator, '/', rez.denominator, sep='')


from fractions import Fraction

def get_CDF_fraction(A, B, C):
	if A > B:
		(A, B) = (B, A)
	denom = 2 * A * B
	if C <= 0:
		numer = 0
	elif 0 < C <= A:
		numer = C ** 2
	elif A < C <= B:
		numer = 2 * A * C - A ** 2
	elif B < C <= A + B:
		numer = -(A ** 2 + B ** 2 + C ** 2) + 2 * (A + B) * C
	elif A + B < C:
		numer = 2 * A * B
	else:
		assert False
	fr = Fraction(numer, denom)
	return (fr.numerator, fr.denominator)
num_lines = int(input())
for _ in range(num_lines):
	numbers = [int(num) for num in input().split()]
	(numer, denom) = get_CDF_fraction(*numbers)
	print(numer, '/', denom, sep='')


from fractions import Fraction as F
for T in range(int(input())):
	(A, B, C) = map(int, input().split())
	if A + B <= C:
		f = F(1, 1)
	elif C <= A and C <= B:
		f = F(C ** 2, 2 * A * B)
	elif C <= B:
		f = F(2 * C * A - A ** 2, 2 * A * B)
	elif C <= A:
		f = F(2 * C * B - B ** 2, 2 * A * B)
	else:
		f = F(2 * C * (A + B) - A ** 2 - B ** 2 - C ** 2, 2 * A * B)
	print(f.numerator, '/', f.denominator, sep='')


import math
import sys

def gcd(A, B):
	if B == 0:
		return A
	else:
		return gcd(B, A % B)
T = int(sys.stdin.readline())
for i in range(T):
	(A, B, C) = [int(x) for x in sys.stdin.readline().split()]
	(A, B) = (min(A, B), max(A, B))
	den = 2 * A * B
	if C >= A + B:
		print('1/1')
	else:
		if C <= A:
			num = C * C
		elif A < C <= B:
			num = 2 * A * C - A * A
		else:
			num = 2 * A * (C - A) + 2 * (A + B - C) * (C - B) + (A + B - C) ** 2
		hcf = gcd(num, den)
		print('%d/%d' % (num // hcf, den // hcf))


from itertools import product
from fractions import Fraction
for t in range(int(input())):
	tmp = input().split()
	(A, B, C) = [int(i) for i in tmp]
	if A + B <= C:
		fr = Fraction(1, 1)
	elif C <= A and C <= B:
		fr = Fraction(C ** 2, 2 * A * B)
	elif C <= B:
		fr = Fraction(2 * C * A - A ** 2, 2 * A * B)
	elif C <= A:
		fr = Fraction(2 * C * B - B ** 2, 2 * A * B)
	else:
		fr = Fraction(2 * C * (A + B) - A ** 2 - B ** 2 - C ** 2, 2 * A * B)
	print(fr.numerator, '/', fr.denominator, sep='')


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
N = int(input())
for _ in range(N):
	[A, B, C] = [int(s) for s in input().split()]
	num = C * C
	if C - B > 0:
		num -= (C - B) * (C - B)
	if C - A > 0:
		num -= (C - A) * (C - A)
	if C - A - B > 0:
		num += (C - A - B) * (C - A - B)
	denom = 2 * A * B
	p = gcd(num, denom)
	print(num // p, '/', denom // p, sep='')


import fractions

def f(value, a, b):
	if value != int(value):
		value = int(2 * value)
		a = 2 * a
	gcd = fractions.gcd(a * b, value)
	return (value // gcd, a * b // gcd)
T = int(input())
for _ in range(T):
	(A, B, C) = [int(x) for x in input().split()]
	res = 0
	if A >= C and B >= C:
		res = C * C / 2
	elif A >= C and B <= C:
		res = (2 * C - B) * B / 2
	elif A <= C and B >= C:
		res = (2 * C - A) * A / 2
	else:
		pointA = A + B - C if A + B - C > 0 else 0
		res = A * B - pointA * pointA / 2
	(x, y) = f(res, A, B)
	print('%d/%d' % (x, y))


def gcd(num, denom):
	if num * denom == 0:
		return 1
	_gcd = num
	mod = denom % _gcd
	while mod:
		(_gcd, mod) = (mod, _gcd % mod)
	return _gcd

def fraction_reduction(num, denom):
	_gcd = gcd(num, denom)
	return (num // _gcd, denom // _gcd)
for i in range(int(input())):
	(a, b, c) = [int(x) for x in input().split()]
	base = 2 * a * b
	m = min(a, b)
	if c >= a + b:
		res = base
	else:
		f = False
		if c > (a + b) // 2 + 1:
			c = a + b - c
			f = True
		if c <= m:
			res = c * c
		else:
			res = m * m + 2 * m * (c - m)
		if f:
			res = base - res
	(res, base) = fraction_reduction(res, base)
	print('%s/%s' % (res, base))


import sys

def gcd(a, b):
	return b and gcd(b, a % b) or a
T = int(sys.stdin.readline())
for _ in range(T):
	(A, B, C) = [int(x) for x in sys.stdin.readline().split()]
	(A, B) = (min(A, B), max(A, B))
	domain = 2 * A * B
	if C >= A + B:
		print('1/1')
	else:
		if C <= A:
			cover = C * C
		elif A < C <= B:
			cover = 2 * A * (C - A) + A ** 2
		else:
			cover = 2 * A * (C - A) + 2 * (A + B - C) * (C - B) + (A + B - C) ** 2
		n = gcd(cover, domain)
		print('%d/%d' % (cover // n, domain // n))


from fractions import gcd
T = int(input())
for _ in range(T):
	[a, b, c] = [int(x) for x in input().split()]
	(a, b) = (min(a, b), max(a, b))
	up = 1
	down = 1
	if c <= a:
		up = c * c
		down = 2 * a * b
	elif c <= b:
		up = 2 * c - a
		down = 2 * b
	elif a + b > c:
		up = a + b - c
		up *= up
		down = 2 * a * b
		up = down - up
	base = gcd(up, down)
	up = up // base
	down = down // base
	print('{0}/{1}'.format(up, down))


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if c < a:
		numerator = c * c
		denominator = 2 * a * b
	elif c < b:
		numerator = 2 * c - a
		denominator = 2 * b
	elif c < a + b:
		numerator = 2 * c * (a + b) - a * a - b * b - c * c
		denominator = 2 * a * b
	else:
		numerator = 1
		denominator = 1
	GCD = gcd(numerator, denominator)
	numerator //= GCD
	denominator //= GCD
	print(str(numerator) + '/' + str(denominator))


import sys
import fractions
n = int(sys.stdin.readline())
for i in range(n):
	(a, b, c) = tuple([int(i) for i in sys.stdin.readline().strip().split()])
	if a + b <= c:
		print('1/1')
	else:
		if a < b:
			(a, b) = (b, a)
		d = a * b * 2
		if b >= c:
			v = c * c
		elif a <= c:
			c2 = a + b - c
			v = a * b * 2 - c2 * c2
		else:
			v = c + c - b
			d = 2 * a
		gcd = fractions.gcd(v, d)
		v = v / gcd
		d = d / gcd
		print('%d/%d' % (v, d))


import sys

def gcd(a, b):
	return b and gcd(b, a % b) or a
T = int(sys.stdin.readline())
for _ in range(T):
	(A, B, C) = [int(x) for x in sys.stdin.readline().split()]
	(A, B) = (min(A, B), max(A, B))
	domain = 2 * A * B
	if C >= A + B:
		print('1/1')
	else:
		if C <= A:
			cover = C * C
		elif A < C <= B:
			cover = 2 * A * (C - A) + A ** 2
		else:
			cover = 2 * A * (C - A) + 2 * (A + B - C) * (C - B) + (A + B - C) ** 2
		n = gcd(cover, domain)
		print('%d/%d' % (cover // n, domain // n))


from fractions import Fraction
N = int(input())
for i in range(N):
	line = input()
	(_a, _b, c) = [int(x) for x in line.split()]
	a = min(_a, _b)
	b = max(_a, _b)
	if c < a:
		print(Fraction(c * c, 2 * a * b))
	elif c < b:
		print(Fraction(2 * c - a, 2 * b))
	elif c < a + b:
		print(Fraction(2 * a * b - (a - c + b) ** 2, 2 * a * b))
	else:
		print('1/1')


from fractions import Fraction
T = int(input().strip())
for t in range(T):
	(a, b, c) = [int(x) for x in input().strip().split(' ')]
	if a + b <= c:
		print('1/1')
	else:
		x = 2 * a * b - (a + b - c) ** 2
		if c < a:
			x += (a - c) ** 2
		if c < b:
			x += (b - c) ** 2
		print(Fraction(x, 2 * a * b))


from fractions import Fraction

def prob(A, B, C):
	if C <= B:
		return Fraction(C ** 2, 2 * A * B)
	if B < C <= A:
		return Fraction(2 * C - B, 2 * A)
	if A < C < A + B:
		return Fraction(2 * A * B - (A + B - C) ** 2, 2 * A * B)
	return '1/1'
for _ in range(int(input())):
	(A, B, C) = map(int, input().split())
	if A < B:
		(A, B) = (B, A)
	print(prob(A, B, C))


import sys
import fractions
n = int(input().strip())
while n > 0:
	(A, B, C) = [int(arr_temp) for arr_temp in input().strip().split(' ')]
	numerator = C ** 2 - (max(0, C - A) ** 2 + max(0, C - B) ** 2)
	if C > A + B:
		numerator += (C - B - A) * (C - A - B)
	denominator = 2 * B * A
	f = fractions.Fraction(numerator, denominator)
	print('{0}/{1}'.format(f.numerator, f.denominator))
	n -= 1


import sys
from fractions import Fraction

def gcd(a, b):
	return b and gcd(b, a % b) or a
n = int(input().strip())
for i in range(n):
	(a, b, c) = input().strip().split(' ')
	A = float(a)
	B = float(b)
	C = float(c)
	(A, B) = (min(A, B), max(A, B))
	domain = 2 * A * B
	if C >= A + B:
		print('1/1')
	else:
		if C <= A:
			cover = C * C
		elif A < C <= B:
			cover = 2 * A * (C - A) + A ** 2
		else:
			cover = 2 * A * (C - A) + 2 * (A + B - C) * (C - B) + (A + B - C) ** 2
		n = gcd(cover, domain)
		print('%d/%d' % (cover // n, domain // n))


from fractions import Fraction
import sys
input()
for line in sys.stdin:
	(x, y, z) = [int(x) for x in line.strip().split(' ')]
	(x, y) = sorted([x, y])
	if z >= x + y:
		print('1/1')
	elif z <= x:
		print(Fraction(z * z / 2) / Fraction(x * y))
	elif z <= y:
		n = (z - x + z) * x / 2
		print(Fraction(n) / Fraction(x * y))
	else:
		n = (x + y - z) ** 2 / 2
		print(1 - Fraction(n) / Fraction(x * y))


import sys

def gcd(a, b):
	return b and gcd(b, a % b) or a
T = int(sys.stdin.readline())
for _ in range(T):
	(A, B, C) = [int(x) for x in sys.stdin.readline().split()]
	(A, B) = (min(A, B), max(A, B))
	domain = 2 * A * B
	if C >= A + B:
		print('1/1')
	else:
		if C <= A:
			cover = C * C
		elif A < C <= B:
			cover = 2 * A * (C - A) + A ** 2
		else:
			cover = 2 * A * (C - A) + 2 * (A + B - C) * (C - B) + (A + B - C) ** 2
		n = gcd(cover, domain)
		print('%d/%d' % (cover // n, domain // n))


def gdc(num1, num2):
	x = num1
	y = num2
	while x > 0:
		tmp = x
		x = y % x
		y = tmp
	return (int(num1 / y), int(num2 / y))

def sumFrac(n1, d1, n2, d2):
	return (int(n1 * d2 + n2 * d1), d1 * d2)

def calc(min, max, c):
	(num, dem) = (0, 0)
	if c >= min + max:
		return (1, 1)
	else:
		if c <= min:
			return gdc(c ** 2, 2 * min * max)
		if c > min and c <= max:
			return gdc(2 * c - min, 2 * max)
		if c > max:
			return gdc(-min ** 2 + 2 * c * min - c ** 2 - max ** 2 + 2 * c * max, 2 * min * max)
n = int(input())
for i in range(n):
	l = input().split()
	v = [int(x) for x in l]
	a1 = v[0] if v[0] < v[1] else v[1]
	a2 = v[0] if v[0] >= v[1] else v[1]
	a3 = v[2]
	print('{}/{}'.format(*calc(a1, a2, a3)))


def gcd(a, b):
	if a == 0 or b == 0:
		return a + b
	return gcd(b, a % b)

def print_normal(a, b):
	g = gcd(a, b)
	print(str(a // g) + '/' + str(b // g))
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a + b < c:
		print_normal(1, 1)
	elif c >= a and c >= b:
		print_normal(2 * a * b - (a + b - c) ** 2, 2 * a * b)
	elif c >= a and c < b:
		print_normal(2 * a * (c - a) + a ** 2, 2 * a * b)
	elif c < a and c >= b:
		print_normal(2 * b * (c - b) + b ** 2, 2 * a * b)
	else:
		print_normal(c * c, 2 * a * b)


import sys
from fractions import gcd

def prob(A, B, C):
	if B > A:
		(A, B) = (B, A)
	if C >= A + B:
		return (1, 1)
	total = 2 * A * B
	area = C * C
	if C >= B:
		area -= (C - B) * (C - B)
	if C >= A:
		area -= (C - A) * (C - A)
	return (area, total)

def to_frac(a, b):
	common = gcd(a, b)
	return (int(a / common), int(b / common))
N = int(sys.stdin.readline().strip())
for line in sys.stdin:
	(A, B, C) = [int(x) for x in line.strip().split()]
	(num, denom) = prob(A, B, C)
	(num, denom) = to_frac(num, denom)
	print(str(num) + '/' + str(denom))


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
n = int(input())
for test in range(n):
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	(p, q) = (0, 0)
	if c <= a and c <= b:
		p = c * c
		q = 2 * a * b
	elif c > b and c <= a:
		p = 2 * c - b
		q = 2 * a
	elif c > a and c <= b:
		p = 2 * c - a
		q = 2 * b
	elif c > b and c > a and (c < a + b):
		p = 2 * (a + b) * c - a * a - b * b - c * c
		q = 2 * a * b
	else:
		(p, q) = (1, 1)
	g = gcd(p, q)
	print(str(p // g) + '/' + str(q // g))


from fractions import Fraction as ul

def p(a, b, c):
	if c <= 0:
		return 0
	elif c >= a + b:
		return 1
	elif b < a:
		return p(b, a, c)
	elif c <= a:
		return ul(c ** 2, 2 * a * b)
	elif c <= b:
		return ul((2 * c - a) * a, 2 * a * b)
	else:
		return ul(1, 1) - ul((a + b - c) ** 2, 2 * a * b)
for _ in range(int(input())):
	(a, b, c) = [int(x) for x in input().strip().split(' ')]
	odg = p(a, b, c)
	if odg == 0:
		print('0/1')
	elif odg == 1:
		print('1/1')
	else:
		print(odg)


def a2(x):
	return x * x

def gcd(a, b):
	if a > b:
		return gcd(b, a)
	if a == 0:
		return b
	return gcd(b - b // a * a, a)

def p(a, b, c):
	ab2 = 2 * a * b
	if c >= a + b:
		res = ab2
	elif c >= max(a, b):
		res = ab2 - a2(a + b - c)
	elif min(a, b) <= c and c <= max(a, b):
		res = a2(c) - a2(c - min(a, b))
	else:
		res = a2(c)
	d = gcd(res, ab2)
	return '%s/%s' % (res // d, ab2 // d)
for i in range(int(input())):
	(a, b, c) = map(int, input().split(' '))
	print(p(a, b, c))


import sys

def gcd(a, b):
	return b and gcd(b, a % b) or a
T = int(sys.stdin.readline())
for _ in range(T):
	(A, B, C) = [int(x) for x in sys.stdin.readline().split()]
	(A, B) = (min(A, B), max(A, B))
	domain = 2 * A * B
	if C >= A + B:
		print('1/1')
	else:
		if C <= A:
			cover = C * C
		elif A < C <= B:
			cover = 2 * A * (C - A) + A ** 2
		else:
			cover = 2 * A * (C - A) + 2 * (A + B - C) * (C - B) + (A + B - C) ** 2
		n = gcd(cover, domain)
		print('%d/%d' % (cover // n, domain // n))


import sys

def gcd(a, b):
	return b and gcd(b, a % b) or a
T = int(sys.stdin.readline())
for _ in range(T):
	(A, B, C) = [int(x) for x in sys.stdin.readline().split()]
	(A, B) = (min(A, B), max(A, B))
	domain = 2 * A * B
	if C >= A + B:
		print('1/1')
	else:
		if C <= A:
			cover = C * C
		elif A < C <= B:
			cover = 2 * A * (C - A) + A ** 2
		else:
			cover = 2 * A * (C - A) + 2 * (A + B - C) * (C - B) + (A + B - C) ** 2
		n = gcd(cover, domain)
		print('%d/%d' % (cover // n, domain // n))


def gcd(a, b):
	if a == 0:
		return b
	if b == 0:
		return a
	return gcd(b, a % b)
t = int(input())
for _ in range(t):
	(a, b, c) = (int(x) for x in input().split(' '))
	area = 0
	if c <= b and c <= a:
		area = c * c / 2
	if c > b and c <= a:
		area = b * b / 2 + b * (c - b)
	if c > a and c <= b:
		area = a * a / 2 + a * (c - a)
	if c > a and c > b:
		area = a * b - max(0, a + b - c) * (a + b - c) / 2
	g = gcd(area, a * b)
	print(str(int(area / g)) + '/' + str(int(a * b / g)))


n = int(input().strip())

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
for _ in range(n):
	(num, den) = (0, 1)
	(a, b, c) = [int(i) for i in input().strip().split()]
	if b >= c:
		if a >= c:
			den = 2 * a * b
			num = c * c
		else:
			den = 2 * a * b
			num = a * (2 * c - a)
	elif a <= c - b:
		num = 1
	elif c - b < a <= c:
		den = 2 * a * b
		num = 2 * b * (c - b) + (a + b - c) * (c + b - a)
	else:
		den = 2 * a * b
		num = 2 * b * (c - b) + b * b
	f = gcd(num, den)
	print(str(num // f) + '/' + str(den // f))


def normalize(n, m):
	g = gcd(n, m)
	return str(round(n / g)) + '/' + str(round(m / g))

def gcd(n, m):
	if n == 0:
		return m
	if m == 0:
		return n
	return gcd(m, n % m)
n = int(input())
listOfInputs = [input() for i in range(n)]
for i in range(n):
	A = list(map(int, listOfInputs[i].split()))
	a = A[0]
	b = A[1]
	c = A[2]
	if b > a:
		(a, b) = (b, a)
	if -a + c >= b:
		print('1/1')
	elif c >= a:
		print(normalize(2 * a * b - (b + a - c) * (b + a - c), 2 * a * b))
	elif c >= b:
		print(normalize(b * (2 * c - b), 2 * a * b))
	else:
		print(normalize(c * c, 2 * a * b))


import fractions
N = int(input())
for i in range(N):
	(A, B, C) = [int(x) for x in input().split(' ')]
	if B > A:
		(A, B) = (B, A)
	if C >= A + B:
		(num, denom) = (1, 1)
	elif C >= A:
		num = 2 * A * B - (A + B - C) * (A + B - C)
		denom = 2 * A * B
	elif B <= C < A:
		num = 2 * C - B
		denom = 2 * A
	elif C < B:
		num = C * C
		denom = 2 * A * B
	gcd = fractions.gcd(num, denom)
	if gcd > 1:
		num = int(num / gcd)
		denom = int(denom / gcd)
	print('{0}/{1}'.format(num, denom))


def gcd(a, b):
	if b == 0:
		return a
	if a == 0:
		return b
	return gcd(b, a % b)
n = int(input())
for i in range(0, n):
	x = input('').split()
	a = int(x[0])
	b = int(x[1])
	t = int(x[2])
	if b < a:
		(a, b) = (b, a)
	if a + b <= t:
		print('1/1')
	else:
		den = 2 * a * b
		if t <= a:
			num = t * t
		elif t <= b:
			num = 2 * a * (t - a) + a * a
		else:
			num = 2 * a * b - (a + b - t) * (a + b - t)
		gc = gcd(int(num), int(den))
		print('%d/%d' % (num / gc, den / gc))


import fractions

def prob(a, b, c):
	if a > b:
		tmp = a
		a = b
		b = tmp
	if c < 0:
		return '0/1'
	if 0 <= c <= a:
		y = 2 * a * b
		x = c ** 2
	elif a < c <= b:
		y = 2 * a * b
		x = 2 * a * c - a * a
	elif b < c < a + b:
		x = 2 * a * c + 2 * b * c - a * a - b * b - c * c
		y = 2 * a * b
	else:
		return '1/1'
	div = fractions.gcd(x, y)
	return '%d/%d' % (x / div, y / div)
cases = int(input())
for i in range(cases):
	(a, b, c) = input().strip().split(' ')
	a = int(a)
	b = int(b)
	c = int(c)
	print(prob(a, b, c))


from fractions import gcd
N = int(input())

def solve(a, b, c):
	if a > b:
		(a, b) = (b, a)
	num = c ** 2
	den = 2 * a * b
	if c > a:
		num -= (c - a) ** 2
		if c > b:
			num -= (c - b) ** 2
			if c > a + b:
				num += (c - a - b) ** 2
	div = gcd(num, den)
	num //= div
	den //= div
	return (num, den)
for ii in range(N):
	(a, b, c) = [int(tt) for tt in input().split()]
	(num, den) = solve(a, b, c)
	print('{:d}/{:d}'.format(num, den))


import fractions
for _ in range(int(input())):
	(a, b, c) = [fractions.Fraction(int(x), 1) for x in input().split()]
	ca = max(c - a, 0)
	cb = max(c - b, 0)
	if c < a + b:
		area = fractions.Fraction(1, 2) * (c * c - ca * ca - cb * cb)
		p = area * fractions.Fraction(1, a * b)
		print(str(p.numerator) + '/' + str(p.denominator))
	else:
		print('1/1')


from fractions import Fraction
for i in range(int(input())):
	(a, b, s) = [int(x) for x in input().split()]
	num = s * s - sum(((s - x) ** 2 for x in (a, b) if s > x))
	den = a * b * 2
	res = Fraction(1, 1) if a + b <= s else Fraction(num, den)
	print('{}/{}'.format(res.numerator, res.denominator))


from fractions import Fraction
N = int(input())
for _ in range(N):
	l = list(map(int, input().split(' ')))
	A = int(l[0])
	B = int(l[1])
	C = int(l[2])
	if C >= 0 and A + B <= C:
		print('1/1')
	if 0 > C:
		print('0/1')
	if C >= 0 and A + B > C:
		result = Fraction(pow(min(B, C), 2) + 2 * B * (C - min(B, C)) - (pow(C, 2) - pow(min(A, C), 2)) + 2 * A * (C - min(A, C)), 2 * A * B)
		print(result)


from fractions import Fraction

def read_ints():
	return [int(x) for x in input().strip().split(' ')]

def read_int():
	return int(input().strip())

def compute_solution(a, b, c):
	(a, b) = (min(a, b), max(a, b))
	sol = '1/1'
	if c < a:
		sol = Fraction(c * c, 2 * a * b)
	elif c < b:
		sol = Fraction(2 * c - a, 2 * b)
	elif c < a + b:
		num = 2 * a * b - (a - c + b) ** 2
		den = 2 * a * b
		sol = Fraction(num, den)
	return sol
N = read_int()
for _ in range(N):
	(a, b, c) = read_ints()
	sol = compute_solution(a, b, c)
	print(sol)


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
t = int(input())
for x in range(0, t):
	(a, b, c) = (int(i) for i in input().split())
	numerator = 0
	if a + b <= c:
		numerator = 1
		denominator = 1
	elif a + b > c and c > b and (c > a):
		numerator = a * b - (a + b - c) ** 2 / 2
		denominator = a * b
	elif a + b > c and c > b:
		numerator = (2 * b * c - b * b) / 2
		denominator = a * b
	elif a + b > c and c > a:
		numerator = (2 * a * c - a * a) / 2
		denominator = a * b
	else:
		numerator = c * c / 2
		denominator = a * b
	if numerator % 1 != 0:
		numerator *= 2
		denominator *= 2
	g = gcd(numerator, denominator)
	numerator /= g
	denominator /= g
	numerator = int(numerator)
	denominator = int(denominator)
	print(str(numerator) + '/' + str(denominator))


from fractions import Fraction

def main(A, B, C):
	if C <= 0:
		return '0/1'
	if C >= A + B:
		return '1/1'
	(A, B) = (B, A) if B < A else (A, B)
	prob = Fraction(0, 1)
	if B <= C <= A + B:
		prob += (A + B) * (C - B) - Fraction(1, 2) * (C ** 2 - B ** 2)
		C = B
	if A <= C <= B:
		prob += A * (C - A)
		C = A
	if C <= A:
		prob += Fraction(1, 2) * C ** 2
	prob /= A * B
	return prob
N = int(input().strip())
data = []
for _ in range(N):
	datum = map(int, input().strip().split())
	data.append(datum)
for i in range(N):
	print(main(*data[i]))


gcd = lambda x, y: gcd(y, x % y) if y else x
print('\n'.join(map(lambda p: '{}/{}'.format(p[0] // gcd(p[0], p[1]), p[1] // gcd(p[0], p[1])), map(lambda a, b, c: (a * b * 2 if c >= a + b else c ** 2 if c <= min(a, b) else min(a, b) * (2 * c - min(a, b)) if min(a, b) < c < max(a, b) else a * b * 2 - (a + b - c) ** 2, a * b * 2), *zip(*(map(int, input().split()) for _ in range(int(input()))))))))


import math
from fractions import Fraction

def integral(z, A, C):
	return Fraction(C) * (Fraction(A) - Fraction(z)) - Fraction(1, 2) * (Fraction(A ** 2) - Fraction(z ** 2))
for _ in range(int(input())):
	(A, B, C) = list(map(int, input().split()))
	if A + B <= C:
		print('1/1')
	else:
		z = max(0, C - B)
		mAC = min(A, C)
		S = z * Fraction(B) + integral(z, mAC, C)
		print(S / Fraction(A * B))


N = int(input())

class Rational:

	def __init__(self, num, denom):
		factor = gcd(num, denom)
		while factor != 1:
			num = num / factor
			denom = denom / factor
			factor = gcd(num, denom)
		self.p = int(num)
		self.q = int(denom)

	def get_num(self):
		return self.p

	def get_denom(self):
		return self.q

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def solve(A, B, C):
	if C > B:
		secB = pow(C - B, 2) / 2
	else:
		secB = 0
	if C > A:
		secA = pow(C - A, 2) / 2
	else:
		secA = 0
	if C > A + B:
		secAB = pow(C - (A + B), 2) / 2
	else:
		secAB = 0
	total = pow(C, 2) / 2 - secB - secA + secAB
	denom = A * B
	return Rational(total, denom)
for k in range(N):
	(A, B, C) = tuple([int(x) for x in str.split(input())])
	result = solve(A, B, C)
	print('/'.join([str(result.get_num()), str(result.get_denom())]))


gcd = lambda x, y: gcd(y, x % y) if y else x
print('\n'.join(map(lambda p: '{}/{}'.format(p[0] // gcd(p[0], p[1]), p[1] // gcd(p[0], p[1])), map(lambda a, b, c: (a * b * 2 if c >= a + b else c ** 2 if c <= min(a, b) else min(a, b) * (2 * c - min(a, b)) if min(a, b) < c < max(a, b) else a * b * 2 - (a + b - c) ** 2, a * b * 2), *zip(*(map(int, input().split()) for _ in range(int(input()))))))))


from fractions import Fraction
n = int(input())
for i in range(n):
	(A, B, C) = input().split(' ')
	A = int(A)
	B = int(B)
	C = int(C)
	if C >= A + B:
		p = 1
	else:
		if C <= A and C <= B:
			p = Fraction(C ** 2, 2 * A * B)
		if C > A and C <= B:
			p = Fraction(A * C - Fraction(A ** 2, 2), A * B)
		if C <= A and C > B:
			p = Fraction(C * B - Fraction(B ** 2, 2), A * B)
		if C > A and C > B:
			p = Fraction(-Fraction(A ** 2 + B ** 2 + C ** 2, 2) + A * C + B * C, A * B)
	if p < 1:
		print(Fraction(p))
	else:
		print('1/1')


gcd = lambda x, y: gcd(y, x % y) if y else x
print('\n'.join(map(lambda p: '{}/{}'.format(p[0] // gcd(p[0], p[1]), p[1] // gcd(p[0], p[1])), map(lambda a, b, c: (a * b * 2 if c >= a + b else c ** 2 if c <= min(a, b) else min(a, b) * (2 * c - min(a, b)) if min(a, b) < c < max(a, b) else a * b * 2 - (a + b - c) ** 2, a * b * 2), *zip(*(map(int, input().split()) for _ in range(int(input()))))))))


import fractions
t = int(input().strip())
for test in range(t):
	(a, b, c) = [int(s) for s in input().strip().split()]
	if c == 0:
		print('0/1')
	elif a + b <= c:
		print('1/1')
	elif a <= c and b <= c:
		print(fractions.Fraction(2 * a * b - (a + b - c) ** 2, 2 * a * b))
	elif a <= c and b >= c:
		print(fractions.Fraction(a * (2 * (c - a) + a), 2 * a * b))
	elif a >= c and b <= c:
		print(fractions.Fraction(b * (2 * (c - b) + b), 2 * a * b))
	elif a >= c and b >= c:
		print(fractions.Fraction(c ** 2, 2 * a * b))


from fractions import Fraction
n = int(input())
for i in range(n):
	(a, b, c) = [int(j) for j in input().split()]
	(a, b) = sorted([a, b])
	if c <= a:
		num = c ** 2
	elif c <= b:
		num = 2 * a * c - a ** 2
	elif c <= a + b:
		num = 2 * a * b - (a + b - c) ** 2
	elif c > a + b:
		num = 2 * a * b
	den = 2 * a * b
	ans = Fraction(numerator=num, denominator=den)
	print(str(ans.numerator) + '/' + str(ans.denominator))


def gcd(a, b):
	if a < b:
		(a, b) = (b, a)
	while b != 0:
		temp = a % b
		a = b
		b = temp
	return a

def reform(a, b):
	g = gcd(a, b)
	return '%d/%d' % (a / g, b / g)

def f(a, b, c):
	if a < b:
		(a, b) = (b, a)
	z = a + b
	if c >= z:
		return '1/1'
	elif c >= a:
		s1 = 2 * a * b - (a + b - c) ** 2
		s2 = 2 * a * b
		return reform(s1, s2)
	elif c >= b:
		s1 = 2 * c - b
		s2 = 2 * a
		return reform(s1, s2)
	elif c > 0:
		return reform(c ** 2, 2 * a * b)
	else:
		return '0'
n = int(input())
for i in range(n):
	line = input()
	tokens = line.split(' ')
	tokens = [int(x) for x in tokens]
	print(f(*tokens))


import sys

def gcd(a, b):
	return b and gcd(b, a % b) or a
T = int(sys.stdin.readline())
for _ in range(T):
	(A, B, C) = [int(x) for x in sys.stdin.readline().split()]
	(A, B) = (min(A, B), max(A, B))
	domain = 2 * A * B
	if C >= A + B:
		print('1/1')
	else:
		if C <= A:
			cover = C * C
		elif A < C <= B:
			cover = 2 * A * (C - A) + A ** 2
		else:
			cover = 2 * A * (C - A) + 2 * (A + B - C) * (C - B) + (A + B - C) ** 2
		n = gcd(cover, domain)
		print('%d/%d' % (cover // n, domain // n))


gcd = lambda x, y: gcd(y, x % y) if y else x
print('\n'.join(map(lambda p: '{}/{}'.format(p[0] // gcd(p[0], p[1]), p[1] // gcd(p[0], p[1])), map(lambda a, b, c: (a * b * 2 if c >= a + b else c ** 2 if c <= min(a, b) else min(a, b) * (2 * c - min(a, b)) if min(a, b) < c < max(a, b) else a * b * 2 - (a + b - c) ** 2, a * b * 2), *zip(*(map(int, input().split()) for _ in range(int(input()))))))))


def readInput():
	numLines = input()
	numLines = int(numLines.strip())
	lines = []
	for _ in range(numLines):
		line = input()
		abc = line.split()
		lines.append(tuple([int(x) for x in abc]))
	return lines

def f(a, b, c):
	if a == b == 0:
		return (0, 1)
	if a + b <= c:
		return (1, 1)
	factors = []
	if a > c:
		factors.append((c, a))
		a = c
	if b > c:
		factors.append((c, b))
		b = c
	n = -a ** 2 * c - b ** 2 * c + 2 * b * c ** 2 + 2 * a * c ** 2 - c ** 3
	d = 2 * a * b * c
	for (nfactor, dfactor) in factors:
		n *= nfactor
		d *= dfactor
	return (n, d)

def gcd(a, b):
	while b != 0:
		h = a % b
		a = b
		b = h
	return a

def formatFraction(n, d):
	while True:
		g = gcd(n, d)
		if g == 1:
			return '{}/{}'.format(n, d)
		else:
			n //= g
			d //= g
lines = readInput()
results = [f(*line) for line in lines]
for (n, d) in results:
	print(formatFraction(n, d))


from fractions import gcd
for i in range(int(input())):
	(a, b, c) = (int(x) for x in input().split())
	s = c ** 2 / 2
	if c > a:
		s = s - (c - a) ** 2 / 2
	if c > b:
		s = s - (c - b) ** 2 / 2
	if c >= a + b:
		print('1/1')
	else:
		u = gcd(s, a * b)
		print(str(int(s // u)) + '/' + str(int(a * b // u)))


from fractions import Fraction

def main():
	for i in range(int(input())):
		(a, b, c) = map(int, input().split())
		if a > b:
			(a, b) = (b, a)
		if c <= a:
			result = Fraction(c * c, 2 * a * b)
		elif c <= b:
			result = Fraction(2 * c - a, 2 * b)
		elif c < a + b:
			d = a + b - c
			result = 1 - Fraction(d * d, 2 * a * b)
		else:
			result = Fraction(1)
		print('{}/{}'.format(result.numerator, result.denominator))
main()


import math

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def is_prime(n):
	for i in range(2, 1 + int(math.sqrt(n))):
		if n % i == 0:
			return False
	return True
N = int(input())
for i in range(N):
	(a, b, c) = tuple(map(lambda x: int(x), input().split()))
	if c >= a + b:
		print('1/1')
		continue
	top = c ** 2
	if c > b:
		top = top - (b - c) ** 2
	if c > a:
		top = top - (a - c) ** 2
	bottom = 2 * a * b
	gcd1 = gcd(bottom, top)
	print('%d/%d' % (top / gcd1, bottom / gcd1))


from fractions import Fraction
N = int(input())
for i in range(N):
	(a, b, c) = [int(x) for x in input().split()]
	if b < a:
		btemp = a
		a = b
		b = btemp
	if a + b <= c:
		print('1/1')
	elif c <= b and c <= a:
		out = Fraction(c ** 2, 2 * b * a)
		print(out)
	elif c <= b and c >= a:
		print(Fraction((2 * c - a) * a, 2 * b * a))
	else:
		out = Fraction(c - b, a) + Fraction(c, b) - Fraction(a, 2 * b) - Fraction((c + b) * (c - b), 2 * b * a)
		print(out)


gcd = lambda x, y: gcd(y, x % y) if y else x
print('\n'.join(map(lambda p: '{}/{}'.format(p[0] // gcd(p[0], p[1]), p[1] // gcd(p[0], p[1])), map(lambda a, b, c: (a * b * 2 if c >= a + b else c ** 2 if c <= min(a, b) else min(a, b) * (2 * c - min(a, b)) if min(a, b) < c < max(a, b) else a * b * 2 - (a + b - c) ** 2, a * b * 2), *zip(*(map(int, input().split()) for _ in range(int(input()))))))))


from fractions import Fraction
t = int(input().strip())
for i in range(t):
	(a, b, c) = tuple(map(int, input().split()))
	if a + b < c:
		print('1/1')
	else:
		f = Fraction(c ** 2 - max(c - a, 0) ** 2 - max(c - b, 0) ** 2, a * b * 2)
		print('{}/{}'.format(f.numerator, f.denominator))


from fractions import Fraction
for index in range(int(input())):
	(A, B, C) = map(int, input().split())
	if B < A:
		temp = A
		A = B
		B = temp
	if C <= 0:
		print('0/1')
	elif C < A:
		print(Fraction(C * C, 2 * A * B))
	elif C >= A + B:
		print('1/1')
	elif C >= A and C <= B:
		print(Fraction(2 * C - A, 2 * B))
	else:
		print(Fraction(2 * A * B - (A + B - C) ** 2, 2 * A * B))


from fractions import Fraction
N = int(input())
for n in range(N):
	(a, b, c) = [int(x) for x in input().strip().split()]
	if c <= 0:
		print('0/1')
		continue
	if a + b <= c:
		print('1/1')
	else:
		if c <= min(a, b):
			num = c * c
			den = 2
		elif c >= max(a, b):
			num = 2 * a * b - (a + b - c) * (a + b - c)
			den = 2
		else:
			mn = min(a, b)
			mx = max(a, b)
			num = 2 * (c - mn) * mn + mn * mn
			den = 2
		fr = Fraction(num, den * a * b)
		print(fr)


import fractions

def f(A, B, C):
	if C >= A + B:
		return fractions.Fraction(1, 1)
	if A > B:
		(A, B) = (B, A)
	R = 2 * A * B
	if C <= A:
		L = C * C
	elif C <= B:
		L = (2 * C - A) * A
	else:
		L = 2 * A * B - (A + B - C) * (A + B - C)
	return fractions.Fraction(L, R)
T = int(input())
for k in range(T):
	(A, B, C) = [int(n) for n in input().split()]
	res = f(A, B, C)
	print(str(res.numerator) + '/' + str(res.denominator))


def gcd(a, b):
	if a % b == 0:
		return b
	else:
		return gcd(b, a % b)

def prob(A, B, C):
	if C >= A + B:
		return '1/1'
	left = min(A, B)
	right = max(A, B)
	if C <= left:
		numer = C * C
		denom = 2 * A * B
	elif C <= right:
		numer = 2 * C - left
		denom = 2 * right
	else:
		numer = 2 * A * C + 2 * B * C - A * A - B * B - C * C
		denom = 2 * A * B
	return str(numer // gcd(numer, denom)) + '/' + str(denom // gcd(numer, denom))
out = []
howmany = int(input())
for i in range(howmany):
	line = input()
	line = line.split()
	(a, b, c) = [int(x) for x in line]
	out.append(prob(a, b, c))
for outline in out:
	print(outline)


from fractions import Fraction
n = int(input())
tests = []
for _ in range(n):
	tests.append([int(i) for i in input().split()])
for test in tests:
	(ao, bo, co) = test
	if co <= 0:
		print('0/1')
	elif ao + bo <= co:
		print('1/1')
	else:
		(a, b, c) = (ao, bo, co)
		p = Fraction(0, 1)
		if a < c:
			p += Fraction(a * (c - a), 1)
			b -= c - a
			c = a
		if b < c:
			p += Fraction(b * (c - b), 1)
			a -= c - b
			c = b
		p += Fraction(c ** 2, 2)
		p /= Fraction(ao * bo, 1)
		print(p.numerator, '/', p.denominator, sep='')


N = int(input())

def gcd(a, b):
	while b != 0:
		t = b
		b = a % b
		a = t
	return a
for _ in range(N):
	(A, B, C) = map(int, input().split())
	if C <= A and C <= B:
		num = C * C
		denom = 2 * A * B
	elif C > A and C <= B:
		num = 2 * A * C - A * A
		denom = 2 * A * B
	elif C > B and C <= A:
		num = 2 * B * C - B * B
		denom = 2 * A * B
	elif B - C + A > 0:
		num = 2 * A * B - (B - C + A) * (B - C + A)
		denom = 2 * A * B
	else:
		num = 1
		denom = 1
	if num >= denom:
		print('1/1')
	else:
		g = gcd(denom, num)
		print('/'.join([str(num // g), str(denom // g)]))


gcd = lambda x, y: gcd(y, x % y) if y else x
print('\n'.join(map(lambda p: '{}/{}'.format(p[0] // gcd(p[0], p[1]), p[1] // gcd(p[0], p[1])), map(lambda a, b, c: (a * b * 2 if c >= a + b else c ** 2 if c <= min(a, b) else min(a, b) * (2 * c - min(a, b)) if min(a, b) < c < max(a, b) else a * b * 2 - (a + b - c) ** 2, a * b * 2), *zip(*(map(int, input().split()) for _ in range(int(input()))))))))


n = int(input())

def gcd(a, b):
	return a if b == 0 else gcd(b, a % b)

def div(a, b):
	d = gcd(a, b)
	return (a // d, b // d)

def check(a, b, c):
	if a + b <= c:
		return (1, 1)
	ma = min(a, b)
	mb = max(a, b)
	if c <= ma:
		return div(c * c, a * b * 2)
	if c >= mb:
		return div(a * b * 2 - (a + b - c) * (a + b - c), a * b * 2)
	return div((c * 2 - ma) * ma, a * b * 2)
for _ in range(n):
	(a, b, c) = [int(x) for x in input().split()]
	print('{}/{}'.format(*check(a, b, c)))


from fractions import gcd
t = int(input().strip())
for _ in range(t):
	(a, b, c) = [int(x) for x in input().strip().split(' ')]
	if a + b <= c:
		print('1/1')
	elif a == 0:
		g = gcd(b, c)
		print(str(c // g) + '/' + str(b // g))
	elif b == 0:
		g = gcd(a, c)
		print(str(c // g) + '/' + str(a // g))
	else:
		pos_num = c * c
		pos_den = 2
		if a < c:
			pos_num = 2 * pos_num - (c - a) * (c - a) * pos_den
			pos_den *= 2
		if b < c:
			pos_num = 2 * pos_num - (c - b) * (c - b) * pos_den
			pos_den *= 2
		den = pos_den * a * b
		g = gcd(pos_num, den)
		print(str(pos_num // g) + '/' + str(den // g))


from fractions import Fraction
n = int(input())
p = []
for i in range(n):
	s = input().split()
	if int(s[0]) >= int(s[1]):
		A = int(s[0])
		B = int(s[1])
	else:
		A = int(s[1])
		B = int(s[0])
	C = int(s[2])
	if C >= A + B:
		P = 1
	elif C <= B:
		P = Fraction(C ** 2, 2 * A * B)
	elif C <= A:
		P = Fraction(B, 2 * A) + Fraction(C - B, A)
	else:
		P = 1 - Fraction((A + B - C) ** 2, 2 * A * B)
	p.append(P)
for i in range(n):
	if p[i] == 1:
		print('1/1')
	else:
		print(Fraction(p[i]))


from fractions import Fraction

def get_prob(A, B, C):
	total_area = A * B
	if C < 0:
		return 0
	elif C < B:
		if C < A:
			area = Fraction(C ** 2, 2)
		else:
			area = Fraction((2 * C - A) * A, 2)
	elif C < A:
		area = Fraction((2 * C - B) * B, 2)
	elif C < A + B:
		area = Fraction(2 * A * B - (A + B - C) ** 2, 2)
	else:
		return '1/1'
	return area / total_area
n = int(input())
for _ in range(n):
	(A, B, C) = [int(x) for x in input().split()]
	prob = get_prob(A, B, C)
	print(prob)


from fractions import Fraction

def reduc(a, b):
	return Fraction(a, b)
N = int(input())
while N > 0:
	(a, b, c) = [int(j) for j in input().split()]
	if c <= a and c <= b:
		f = Fraction(c ** 2, 2 * a * b)
		print('{0}/{1}'.format(f.numerator, f.denominator))
	elif c < a:
		f = Fraction(c ** 2 - (c - b) ** 2, 2 * a * b)
		print('{0}/{1}'.format(f.numerator, f.denominator))
	elif c < b:
		f = Fraction(c ** 2 - (c - a) ** 2, 2 * a * b)
		print('{0}/{1}'.format(f.numerator, f.denominator))
	elif a + b > c:
		f = Fraction(c ** 2 - (c - a) ** 2 - (c - b) ** 2, 2 * a * b)
		print('{0}/{1}'.format(f.numerator, f.denominator))
	else:
		print('1/1')
	N -= 1


gcd = lambda x, y: gcd(y, x % y) if y else x
print('\n'.join(map(lambda p: '{}/{}'.format(p[0] // gcd(p[0], p[1]), p[1] // gcd(p[0], p[1])), map(lambda a, b, c: (a * b * 2 if c >= a + b else c ** 2 if c <= min(a, b) else min(a, b) * (2 * c - min(a, b)) if min(a, b) < c < max(a, b) else a * b * 2 - (a + b - c) ** 2, a * b * 2), *zip(*(map(int, input().split()) for _ in range(int(input()))))))))


def gcf(num1, num2):
	x1 = max(num1, num2)
	x2 = min(num1, num2)
	r = x2
	while x1 % x2 != 0:
		r = x1 % x2
		x1 = x2
		x2 = r
	return r
n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split(' '))
	if c >= a + b:
		numerator = 1
		denominator = 1
	elif c >= b and c >= a:
		numerator = 2 * a * b - (a - (c - b)) * (b - (c - a))
		denominator = 2 * a * b
	elif c >= b and c <= a:
		numerator = (c + c - b) * b
		denominator = 2 * a * b
	elif c >= a and c <= b:
		numerator = (2 * c - a) * a
		denominator = 2 * a * b
	elif c <= a and c <= b:
		numerator = c * c
		denominator = 2 * a * b
	factor = gcf(numerator, denominator)
	numerator = numerator / factor
	denominator = denominator / factor
	print('%d/%d' % (numerator, denominator))


def greatest_common_divisor(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
for _ in range(int(input())):
	(A, B, C) = map(int, input().split())
	(A, B) = sorted([A, B])
	if A + B <= C:
		print('1/1')
		continue
	elif B <= C:
		area = 2 * A * B - (A + B - C) * (A + B - C)
	elif A >= C:
		area = C * C
	else:
		area = A * (2 * C - A)
	num = area
	den = A * B * 2
	gcd = greatest_common_divisor(num, den)
	print('{}/{}'.format(num // gcd, den // gcd))


gcd = lambda x, y: gcd(y, x % y) if y else x
print('\n'.join(map(lambda p: '{}/{}'.format(p[0] // gcd(p[0], p[1]), p[1] // gcd(p[0], p[1])), map(lambda a, b, c: (a * b * 2 if c >= a + b else c ** 2 if c <= min(a, b) else min(a, b) * (2 * c - min(a, b)) if min(a, b) < c < max(a, b) else a * b * 2 - (a + b - c) ** 2, a * b * 2), *zip(*(map(int, input().split()) for _ in range(int(input()))))))))


from fractions import Fraction
T = int(input().strip())
for case in range(T):
	(A, B, C) = map(int, input().strip().split(' '))
	if A + B <= C:
		print('1/1')
	else:
		norm = 2 * A * B
		P = C ** 2
		if A < C:
			P = P - (C - A) ** 2
		if B < C:
			P = P - (C - B) ** 2
		print(Fraction(P, norm))


def gcd(a, b):
	if a % b == 0:
		return b
	else:
		return gcd(b, a % b)
n = int(input().strip())
for i in range(n):
	(a, b, c) = [int(x) for x in input().strip().split()]
	if a + b <= c:
		n = 1
		d = 1
	elif c <= a and c <= b:
		n = c * c
		d = 2 * b * a
	elif a <= c and b <= c:
		n = 2 * a * b - (a + b - c) * (a + b - c)
		d = 2 * a * b
	elif a >= c and b <= c:
		n = c * c - (c - b) * (c - b)
		d = 2 * a * b
	elif b >= c and a <= c:
		n = c * c - (c - a) * (c - a)
		d = 2 * a * b
	g = gcd(n, d)
	print(str(int(n / g)) + '/' + str(int(d / g)))


from fractions import Fraction
import math
n = int(input())
for a0 in range(n):
	(a, b, c) = [int(t) for t in input().strip().split(' ')]
	if a + b <= c:
		print('1/1')
	else:
		if c <= min(a, b):
			p = Fraction(c ** 2, 2 * a * b)
		elif a <= c & c <= b:
			p = Fraction(2 * c - a, 2 * b)
		elif c > max(a, b):
			p = Fraction(2 * a * b - (a + b - c) ** 2, 2 * a * b)
		else:
			p = Fraction(2 * c - b, 2 * a)
		print('{}/{}'.format(p.numerator, p.denominator))


from fractions import gcd
tests = input()
output_list = []

def abc_answer(a, b, c):
	if c - b > a:
		return (1, 1)
	elif c - b > 0:
		if c < a:
			return (2 * c - b, 2 * a)
		else:
			return (2 * b * c + 2 * a * c - a * a - b * b - c * c, 2 * a * b)
	elif c < a:
		return (c * c, 2 * a * b)
	else:
		return (2 * c - a, 2 * b)

def ans_format(a):
	factor = gcd(a[0], a[1])
	a0 = int(a[0] / factor)
	a1 = int(a[1] / factor)
	a_str = str(a0) + '/' + str(a1)
	return a_str
for i in range(int(tests)):
	abc = input().split()
	a = int(abc[0])
	b = int(abc[1])
	c = int(abc[2])
	ans = abc_answer(a, b, c)
	ans_final = ans_format(ans)
	print(ans_final)


from fractions import Fraction
N = int(input())
for _ in range(N):
	(A, B, C) = list(map(int, input().split()))
	(A, B) = (min(A, B), max(A, B))
	m1 = Fraction(min(A, C))
	m2 = Fraction(min(A, max(0, C - B)))
	p = B * m2 + C * (m1 - m2) - (m1 ** 2 - m2 ** 2) / 2
	p /= A * B
	print('%d/%d' % (p.numerator, p.denominator))


from fractions import gcd
N = int(input())
for i in range(N):
	(A, B, C) = (int(j) for j in input().split())
	Total = A * B
	if C <= min(A, B):
		D = C * C
	elif C <= max(A, B):
		D = C * C - (C - min(A, B)) ** 2
	elif C <= A + B:
		D = A * B * 2 - (min(A, B) - (C - max(A, B))) ** 2
	else:
		D = 2 * A * B
	k = gcd(D, Total * 2)
	print(str(int(D / k)) + '/' + str(int(Total * 2 / k)))


gcd = lambda x, y: gcd(y, x % y) if y else x
print('\n'.join(map(lambda p: '{}/{}'.format(p[0] // gcd(p[0], p[1]), p[1] // gcd(p[0], p[1])), map(lambda a, b, c: (a * b * 2 if c >= a + b else c ** 2 if c <= min(a, b) else min(a, b) * (2 * c - min(a, b)) if min(a, b) < c < max(a, b) else a * b * 2 - (a + b - c) ** 2, a * b * 2), *zip(*(map(int, input().split()) for _ in range(int(input()))))))))


gcd = lambda x, y: gcd(y, x % y) if y else x
print('\n'.join(map(lambda p: '{}/{}'.format(p[0] // gcd(p[0], p[1]), p[1] // gcd(p[0], p[1])), map(lambda a, b, c: (a * b * 2 if c >= a + b else c ** 2 if c <= min(a, b) else min(a, b) * (2 * c - min(a, b)) if min(a, b) < c < max(a, b) else a * b * 2 - (a + b - c) ** 2, a * b * 2), *zip(*(map(int, input().split()) for _ in range(int(input()))))))))


from fractions import Fraction
cases = int(input().strip())
for _ in range(cases):
	(a, b, c) = input().split()
	a = int(a.strip())
	b = int(b.strip())
	c = int(c.strip())
	if a > b:
		(a, b) = (b, a)
	if c >= a + b:
		(pn, pd) = (1, 1)
	elif c < a:
		pn = c ** 2
		pd = 2 * a * b
	elif a <= c < b:
		pn = 2 * c - a
		pd = 2 * b
	else:
		pn = 2 * a * b - (a + b - c) ** 2
		pd = 2 * a * b
	if pn / pd == 1:
		print('1/1')
	else:
		print(Fraction(pn, pd))


from fractions import Fraction
for n in range(int(input())):
	(A, B, C) = map(int, input().split())
	if A + B <= C:
		print('1/1')
	elif (A >= C) & (B >= C):
		print(Fraction(C * C, 2 * A * B))
	elif (A >= C) ^ (B >= C):
		print(Fraction(2 * C - min(A, B), 2 * max(A, B)))
	else:
		print(Fraction(2 * A * B - (A + B - C) ** 2, 2 * A * B))


from fractions import Fraction
T = int(input())

def heh(m, c, v):
	return min(c, max(v, m))
for t in range(T):
	[A, B, C] = [int(i) for i in input().split(' ')]
	if A + B <= C:
		print('1/1')
		continue
	C_area = C * C
	if B < C:
		C_area -= (C - B) ** 2
	if A < C:
		C_area -= (C - A) ** 2
	f = Fraction(C_area, A * B * 2)
	print(f)


numTests = int(input())
gcd = lambda x, y: gcd(y, x % y) if y else x
for _ in range(numTests):
	(A, B, C) = map(int, input().split())
	if C < A and C < B:
		num = C * C
		den = 2 * A * B
	elif A <= C and C <= B:
		num = A * (2 * C - A)
		den = 2 * A * B
	elif B <= C and C <= A:
		num = B * (2 * C - B)
		den = 2 * A * B
	elif A < C and B < C and (A + B > C):
		num = -(A - C) ** 2 - B * (B - 2 * C)
		den = 2 * A * B
	elif A + B <= C:
		num = 1
		den = 1
	print('{}/{}'.format(num // gcd(num, den), den // gcd(num, den)))