Ворошилова Ксения Михайловна 318 ArbTangent 6593
Инюшин Алексей 317 ArbTangent 5897
f1from decimal import *f1from decimal import *
22
n3def calculate_pi():n3def pi():
4    three = Decimal(3)4    three = Decimal(3)
n5    previous_sum, term, total_sum, numerator, numerator_addend, denominan5    lasts, t, s, n, na, d, da = (0, three, 3, 1, 0, 0, 24)
>tor, denominator_addend = (0, three, 3, 1, 0, 0, 24) 
6    while total_sum != previous_sum:6    while s != lasts:
7        previous_sum = total_sum7        lasts = s
8        numerator, numerator_addend = (numerator + numerator_addend, num8        n, na = (n + na, na + 8)
>erator_addend + 8) 
9        denominator, denominator_addend = (denominator + denominator_add9        d, da = (d + da, da + 32)
>end, denominator_addend + 32) 
10        term = term * numerator / denominator10        t = t * n / d
11        total_sum += term11        s += t
12    return total_sum12    return s
1313
n14def calculate_cosine(x):n14def cos(x):
15    index, previous_sum, total_sum, factorial, numerator, sign = (0, 0, 15    i, lasts, s, fact, num, sign = (0, 0, 1, 1, 1, 1)
>1, 1, 1, 1) 
16    while total_sum != previous_sum:16    while s != lasts:
17        previous_sum = total_sum17        lasts = s
18        index += 218        i += 2
19        factorial *= index * (index - 1)19        fact *= i * (i - 1)
20        numerator *= x * x20        num *= x * x
21        sign *= -121        sign *= -1
n22        total_sum += numerator / factorial * signn22        s += num / fact * sign
23    return total_sum23    return s
2424
n25def calculate_sine(x):n25def sin(x):
26    index, previous_sum, total_sum, factorial, numerator, sign = (1, 0, 26    i, lasts, s, fact, num, sign = (1, 0, x, 1, x, 1)
>x, 1, x, 1) 
27    while total_sum != previous_sum:27    while s != lasts:
28        previous_sum = total_sum28        lasts = s
29        index += 229        i += 2
30        factorial *= index * (index - 1)30        fact *= i * (i - 1)
31        numerator *= x * x31        num *= x * x
32        sign *= -132        sign *= -1
t33        total_sum += numerator / factorial * signt33        s += num / fact * sign
34    return total_sum34    return s
35angle_in_radians = Decimal(input())35A, E = (Decimal(input()), int(input()))
36precision = int(input())
37getcontext().prec = precision + 536getcontext().prec = E + 5
38result = angle_in_radians * calculate_pi() / Decimal(200)37r = A * pi() / Decimal(200)
39tangent = calculate_sine(result) / calculate_cosine(result)38r = sin(r) / cos(r)
40getcontext().prec = precision39getcontext().prec = E
41print(+tangent)40print(+r)
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op