Hide

Problem D
Deutsche Post

You just got a letter from Germany containing Python code. Some German has asked you to compute the output of the code. You might think that this is impossible, but thankfully the code takes no input, and will terminate without errors in finite time. Additionally, the code is completely deterministic. How nice of our unknown German sender!

Input

The first line of input contains the integer $N$, ($1 \leq N \leq 1000$), the number of lines that the python file contains.

The following $N$ lines each contain one line of Python code. The total number of characters is less than $2000$.

Output

Run the program, and it will output the correct answer (eventually).

Sample Input 1 Sample Output 1
6
import math

s = 0
for i in range(1, 1000000):
    s += 1 / (i * i)
print(f"{math.sqrt(s * 6):.7f}")
3.1415917
Sample Input 2 Sample Output 2
2
approximation_8 = 987654321 / 123456789
print(f"{approximation_8:.11f}")
8.00000007290
Sample Input 3 Sample Output 3
16
def approximate_x(x):
    # Approximates x
    # Takes O(x^2) time ignoring log factors, so technically exponential...?
    # (assuming that python has O(Nlog(N)^k)) bignum multiplication)
    # Whatever, some guy got famous saying "embrace exponentials"

    x += 2
    denominator = [i for i in range(1,x)]  # b = 123456789 in base 10
    numerator = list(reversed(denominator))  # a = 987654321 in base 10
    base10_denominator = sum(digit * (x ** i) for i, digit in enumerate(reversed(denominator)))
    base10_numerator = sum(digit * (x ** i) for i, digit in enumerate(reversed(numerator)))

    return base10_numerator / base10_denominator

for x in range(14):
    print(f"approximate_x({x})=\t{approximate_x(x):.15f}")
approximate_x(0)=  1.000000000000000
approximate_x(1)=       1.400000000000000
approximate_x(2)=       2.111111111111111
approximate_x(3)=       3.020618556701031
approximate_x(4)=       4.002680965147453
approximate_x(5)=       5.000262295081967
approximate_x(6)=       6.000020444462617
approximate_x(7)=       7.000001321561743
approximate_x(8)=       8.000000072900001
approximate_x(9)=       9.000000003504939
approximate_x(10)=      10.000000000149280
approximate_x(11)=      11.000000000005706
approximate_x(12)=      12.000000000000197
approximate_x(13)=      13.000000000000007

Please log in to submit a solution to this problem

Log in