t | from decimal import * | t | from decimal import * |
| import math | | import math |
| | | |
| def pi(): | | def pi(): |
| getcontext().prec += 2 | | getcontext().prec += 2 |
| three = Decimal(3) | | three = Decimal(3) |
| (lasts, t, s, n, na, d, da) = (0, three, 3, 1, 0, 0, 24) | | (lasts, t, s, n, na, d, da) = (0, three, 3, 1, 0, 0, 24) |
| while s != lasts: | | while s != lasts: |
| lasts = s | | lasts = s |
| (n, na) = (n + na, na + 8) | | (n, na) = (n + na, na + 8) |
| (d, da) = (d + da, da + 32) | | (d, da) = (d + da, da + 32) |
| t = t * n / d | | t = t * n / d |
| s += t | | s += t |
| getcontext().prec -= 2 | | getcontext().prec -= 2 |
| return +s | | return +s |
| | | |
| def cos(x): | | def cos(x): |
| getcontext().prec += 2 | | getcontext().prec += 2 |
| (i, lasts, s, fact, num, sign) = (0, 0, 1, 1, 1, 1) | | (i, lasts, s, fact, num, sign) = (0, 0, 1, 1, 1, 1) |
| while s != lasts: | | while s != lasts: |
| lasts = s | | lasts = s |
| i += 2 | | i += 2 |
| fact *= i * (i - 1) | | fact *= i * (i - 1) |
| num *= x * x | | num *= x * x |
| sign *= -1 | | sign *= -1 |
| s += num / fact * sign | | s += num / fact * sign |
| getcontext().prec -= 2 | | getcontext().prec -= 2 |
| return +s | | return +s |
| | | |
| def sin(x): | | def sin(x): |
| getcontext().prec += 2 | | getcontext().prec += 2 |
| (i, lasts, s, fact, num, sign) = (1, 0, x, 1, x, 1) | | (i, lasts, s, fact, num, sign) = (1, 0, x, 1, x, 1) |
| while s != lasts: | | while s != lasts: |
| lasts = s | | lasts = s |
| i += 2 | | i += 2 |
| fact *= i * (i - 1) | | fact *= i * (i - 1) |
| num *= x * x | | num *= x * x |
| sign *= -1 | | sign *= -1 |
| s += num / fact * sign | | s += num / fact * sign |
| getcontext().prec -= 2 | | getcontext().prec -= 2 |
| return +s | | return +s |
| angle = input() | | angle = input() |
| num = int(input()) | | num = int(input()) |
| if num <= 15: | | if num <= 15: |
| angle = float(angle) * math.pi * 0.005 | | angle = float(angle) * math.pi * 0.005 |
| getcontext().prec = num | | getcontext().prec = num |
| print(Decimal(math.tan(angle)) / Decimal(1)) | | print(Decimal(math.tan(angle)) / Decimal(1)) |
| else: | | else: |
| getcontext().prec = num + 2 | | getcontext().prec = num + 2 |
| angle = Decimal(angle) * Decimal('0.005') * pi() | | angle = Decimal(angle) * Decimal('0.005') * pi() |
| answer = sin(Decimal(angle)) / cos(Decimal(angle)) | | answer = sin(Decimal(angle)) / cos(Decimal(angle)) |
| getcontext().prec -= 2 | | getcontext().prec -= 2 |
| print(Decimal(answer) / Decimal(1)) | | print(Decimal(answer) / Decimal(1)) |