# Using python for more precision import sys import random import math from decimal import Decimal, getcontext getcontext().prec = 30 # https://docs.python.org/3/library/decimal.html#decimal-recipes def cos(x): """Return the cosine of x as measured in radians. The Taylor series approximation works best for a small value of x. For larger values, first compute x = x % (2 * pi). >>> print(cos(Decimal('0.5'))) 0.8775825618903727161162815826 >>> print(cos(0.5)) 0.87758256189 >>> print(cos(0.5+0j)) (0.87758256189+0j) """ getcontext().prec += 2 i, lasts, s, fact, num, sign = 0, 0, 1, 1, 1, 1 while s != lasts: lasts = s i += 2 fact *= i * (i-1) num *= x * x sign *= -1 s += num / fact * sign getcontext().prec -= 2 return +s def sin(x): """Return the sine of x as measured in radians. The Taylor series approximation works best for a small value of x. For larger values, first compute x = x % (2 * pi). >>> print(sin(Decimal('0.5'))) 0.4794255386042030002732879352 >>> print(sin(0.5)) 0.479425538604 >>> print(sin(0.5+0j)) (0.479425538604+0j) """ getcontext().prec += 2 i, lasts, s, fact, num, sign = 1, 0, x, 1, x, 1 while s != lasts: lasts = s i += 2 fact *= i * (i-1) num *= x * x sign *= -1 s += num / fact * sign getcontext().prec -= 2 return +s random.seed(int(sys.argv[1])) t = int(sys.argv[2]) min_a = int(sys.argv[3]) max_a = int(sys.argv[4]) print(t) for test in range(t): r = Decimal(random.randint(min_a, max_a) / Decimal(2)).sqrt() ang = Decimal(random.uniform(0, math.pi/2)) x = r * cos(ang) y = r * sin(ang) print(format(x, ".25f"), format(y, ".25f"))