AtCoder Beginner Contest 138 - Resistors in Parallel

Given is a sequence of N integers A_1, \ldots, A_N.
Find the (multiplicative) inverse of the sum of the inverses of these numbers, \frac{1}{\frac{1}{A_1} + \ldots + \frac{1}{A_N}}.

-----Constraints-----
 - 1 \leq N \leq 100
 - 1 \leq A_i \leq 1000

-----Input-----
Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_N

-----Output-----
Print a decimal number (or an integer) representing the value of \frac{1}{\frac{1}{A_1} + \ldots + \frac{1}{A_N}}.
Your output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.

-----Sample Input-----
2
10 30

-----Sample Output-----
7.5

\frac{1}{\frac{1}{10} + \frac{1}{30}} = \frac{1}{\frac{4}{30}} = \frac{30}{4} = 7.5.
Printing 7.50001, 7.49999, and so on will also be accepted.

Difficulty: EASY

Starter code:

Solutions:
n = int(input())
a = map(int, input().split())
print(1 / sum((1 / i for i in a)))


n = int(input())
a = map(int, input().split())
print(1 / sum([1 / aa for aa in a]))


N = int(input())
A = list(map(int, input().split()))
c = [1 / i for i in A]
print(1 / sum(c))


input()
(*l,) = map(int, input().split())
print(1 / sum([1 / i for i in l]))


input()
print(1.0 / sum((1.0 / float(x) for x in input().split())))


N = int(input())
A_lis = list(map(int, input().split()))
a = 0
for i in A_lis:
	a += 1 / i
ans = 1 / a
print(ans)


n = int(input())
a = list(map(int, input().split()))
d = 0
for i in range(n):
	d += 1 / a[i]
ans = 1 / d
print(ans)


n = input()
print(1 / sum(map(lambda x: 1 / int(x), input().split())))


N = float(input())
A = [1 / f for f in map(float, input().split())]
print(1 / sum(A))


n = int(input())
print(1 / sum((1 / e for e in map(int, input().split()))))


N = int(input())
S = 0
A = list(map(int, input().split()))
for i in A:
	S += 1 / i
print(1 / S)


n = int(input())
a = list(map(int, input().split()))
print(1 / sum([1 / n for n in a]))


n = int(input())
a = [int(x) for x in input().split()]
print(1 / sum([1 / x for x in a]))


input()
print(1 / sum((1 / int(x) for x in input().split())))


input()
print(1 / sum((1 / int(s) for s in input().split())))


input()
l = list(map(int, input().split()))
s = sum((1 / i for i in l))
print(1 / s)


input()
A = map(int, input().split())
_ = 0
for a in A:
	_ += 1 / a
print(1 / _)


import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
result = 1 / np.sum(1.0 / A)
print(result)


n = int(input())
a = 0
for x in map(int, input().split()):
	a += 1 / x
print(1 / a)


N = int(input())
A = list(map(int, input().split()))
gyakusuu = 0
for i in A:
	gyakusuu += 1 / i
ans = 1 / gyakusuu
print(ans)


_ = input()
print(1 / sum((1 / i for i in list(map(int, input().split())))))


a = input()
print(1 / sum((1 / int(i) for i in input().split())))


num = int(input())
total = 0
str = input().split()
table = list(str)
for i in range(num):
	total += 1 / int(table[i])
total = 1 / total
print(total)


N = input()
A = map(int, input().split())
print(1 / sum((1 / a for a in A)))


(n, *a) = map(int, open(0).read().split())
print(1 / sum([1 / x for x in a]))


N = input()
As = input().split()
F = [1 / int(x) for x in As]
print(1 / sum(F))


n = int(input())
a = map(int, input().split())
b = 0
for i in a:
	b += 1 / i
print(1 / b)


N = int(input())
A = list(map(int, input().split()))
tmp = 0
for a in A:
	tmp += 1 / a
ret = 1 / tmp
print(ret)


import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque, Counter
from decimal import Decimal
import functools

def v():
	return input()

def k():
	return int(input())

def S():
	return input().split()

def I():
	return map(int, input().split())

def X():
	return list(input())

def L():
	return list(input().split())

def l():
	return list(map(int, input().split()))

def lcm(a, b):
	return a * b // math.gcd(a, b)
sys.setrecursionlimit(10 ** 6)
mod = 10 ** 9 + 7
cnt = 0
ans = 0
inf = float('inf')
al = 'abcdefghijklmnopqrstuvwxyz'
AL = al.upper()
N = k()
A = l()
for i in A:
	ans += 1 / i
ans = 1 / ans
print(ans)


_ = int(input())
print(1 / sum((1 / a for a in list(map(int, input().split())))))


N = int(input())
a = [1 / int(x) for x in input().split()]
print(1 / sum(a))


n = int(input())
li = [1 / float(i) for i in input().split()]
print(1 / sum(li))


N = int(input())
AN = [1 / int(x) for x in input().split()]
print(1 / sum(AN))


input()
a = list(map(int, input().split()))
print(1 / sum(map(lambda x: 1 / x, a)))


N = int(input())
A = input().split()
A = [1 / int(i) for i in A]
print(1 / sum(A))


n = int(input())
s = input().split()
p = 0
for i in s:
	p += 1 / int(i)
print(1 / p)


N = int(input())
A = list(map(int, input().split()))
s = 0
for i in range(N):
	s += 1 / A[i]
print(1 / s)


n = int(input())
a = list(map(int, input().split()))
b = []
for x in a:
	b.append(1 / x)
c = sum(b)
ans = 1 / c
print(ans)


N = int(input())
A = list(map(int, input().split()))
ans = 0
for a in A:
	if a == 0:
		continue
	ans += 1 / a
if ans == 0:
	print(0)
else:
	print(1 / ans)


n = int(input())
a = [float(i) ** (-1) for i in input().split()]
print(1 / sum(a))


n = int(input())
l = map(int, input().split())
m = 0
for i in l:
	m += 1 / i
print(1 / m)


n = int(input())
l = list(map(int, input().split()))
s = 0
for i in l:
	s += 1 / i
print(1 / s)


n = int(input())
nums = map(int, input().split())
re_nums = [1 / num for num in nums]
print(1 / sum(re_nums))


import numpy as np
(N, *A) = map(int, open(0).read().split())
print(1 / np.sum(1 / np.array(A)))


n = int(input())
lst = list(map(int, input().split()))
tmp = 0
for i in range(n):
	tmp = tmp + 1 / lst[i]
print(1 / tmp)


n = int(input())
a = map(int, input().split())
print(1.0 / sum((1.0 / a for a in a)))


a = int(input())
b = list(map(int, input().split()))
A = 1
B = 0
for i in range(a):
	A *= b[i]
for i in range(a):
	B += A / b[i]
print(A / B)


(n, l) = open(0)
print(1 / sum((1 / int(i) for i in l.split())))


_ = int(input())
print(1 / sum([1 / int(a) for a in input().split()]))


(_, l) = open(0)
a = map(lambda x: 1 / int(x), l.split())
print(1 / sum(a))


input()
a = list(map(int, input().split()))
print(1 / sum((1 / ai for ai in a)))


n = int(input())
ss = sum([1 / int(i) for i in input().split()])
print(1 / ss)


n = int(input())
a = list(map(int, input().split()))
prod = a[0]
for A in a[1:]:
	prod *= A
sumprod = 0
for A in a:
	sumprod += prod // A
print(prod / sumprod)


N = int(input())
a = [1.0 / float(x) for x in input().split()]
print(1.0 / sum(a))


_ = int(input())
print(1 / sum([1.0 / i for i in map(int, input().split())]))


n = int(input())
a = list(map(int, input().split()))
targ = 0
for j in a:
	targ += 1 / j
print(1 / targ)


N = int(input())
A = [1 / int(inp) for inp in input().split()]
print(1 / sum(A))


print(1 / sum(list(map(lambda x: 1 / int(x), open(0).read().split()[1:]))))


_ = input()
a = list(map(int, input().split()))
ans = 0
for i in a:
	ans += 1 / i
print(1 / ans)


N = int(input())
As = [1 / int(i) for i in input().split()]
print(1 / sum(As))


n = int(input())
a = list(map(int, input().split()))
S = 0
for i in range(n):
	S += 1 / a[i]
print(1 / S)


N = int(input())
A = [1 / int(a) for a in input().split()]
ans = 1 / sum(A)
print(ans)


def resolve():
	n = int(input())
	a = [1 / int(i) for i in input().split()]
	print(1 / sum(a))
resolve()


input()
print(1 / sum([1 / a for a in map(int, input().split())]))


num = int(input())
r = [1 / int(i) for i in input().split()]
print(1 / sum(r))


n = int(input())
print(1.0 / sum([1.0 / int(i) for i in input().split()]))


n = int(input())
s = list(map(int, input().split()))
t = []
v = 0
for i in range(n):
	c = 1 / s[i]
	t.append(c)
for j in range(n):
	v += t[j]
ans = 1 / v
print(ans)


def mapt(fn, *args):
	return tuple(map(fn, *args))

def Input():
	return mapt(int, input().split(' '))

def aaa(num):
	return 1 / num

def main():
	n = int(input())
	a = Input()
	ans = 1 / sum((aaa(i) for i in a))
	print(ans)
main()


N = int(input())
A = map(int, input().split())
print('{:.16g}'.format(1 / sum((1 / x for x in A))))


N = int(input())
A = list(map(int, input().split()))
print(1 / sum((1 / v for v in A)))


input()
a = list(map(int, input().split()))
s = 0
for it in a:
	s += 1 / it
print(1 / s)


N = input()
R = 0
for s in input().split():
	R += 1 / int(s)
print(1 / R)


n = int(input())
L = list(map(int, input().split()))
print(1 / sum([1 / i for i in L]))


n = int(input())
p = input().split()
p = [1 / int(i) for i in p]
print(1 / sum(p))


N = int(input())
A = list(map(int, input().split()))
check = 0
from decimal import Decimal
for i in range(N):
	check += Decimal(1 / A[i])
ans = Decimal(1 / check)
print(ans)


N = int(input())
print('{:f}'.format(1 / sum([1 / int(i) for i in input().split()])))


n = int(input())
n_list = [1 / int(x) for x in input().split()]
print(1 / sum(n_list))


N = int(input())
print(1 / sum([1 / a for a in list(map(int, input().split()))]))


input()
print(1 / sum((1 / int(num) for num in input().split())))


import numpy as np
n = int(input())
l = [np.array(input().split(), dtype=np.int64)]
l2 = []
for i in range(len(l)):
	l2.append(1 / l[i])
	sum1 = np.sum(l2)
	ans = 1 / sum1
print(ans)


from fractions import Fraction
from typing import List

def answer(n: int, a: List[int]) -> float:
	f = Fraction(1, sum((Fraction(1, i) for i in a)))
	return f.numerator / f.denominator

def main():
	n = int(input())
	a = list(map(int, input().split()))
	print(answer(n, a))

def __starting_point():
	main()
__starting_point()


N = int(input())
print(1 / sum([1 / float(a) for a in input().split()]))


N = int(input())
a = 0.0
for i in input().split():
	a += 1.0 / float(i)
print(1.0 / a)


n = int(input())
A = list(map(int, input().split()))
s = sum([1 / i for i in A])
print(1 / s)


n = int(input())
a = [int(x) for x in input().split()]
c = 0
for i in range(n):
	c += 1 / a[i]
print(1 / c)


N = int(input())
A = map(int, input().split())
S = 0
for a in A:
	S += 1 / a
print(1 / S)


n = int(input())
list_a = [int(i) for i in input().split()]
ans = 0.0
for i in range(0, n):
	ans += 1 / list_a[i]
	if i == n - 1:
		ans = 1 / ans
print(ans)


n = int(input())
a = [1 / int(i) for i in input().split()]
ans = 1 / sum(a)
print(ans)


n = int(input())
lis = list(map(int, input().split()))
total = 0
for i in lis:
	x = 1 / i
	total += x
print(1 / total)


N = int(input())
A = [1 / int(x) for x in input().rstrip().split()]
print(1 / sum(A))


N = int(input())
t = 0
for i in input().split():
	i = int(i)
	t += 1.0 / i
print(1.0 / t)


(N, *A) = map(int, open(0).read().split())
print(1 / sum((1 / v for v in A)))


n = int(input())
a = list(map(int, input().split()))
sum = 0
for i in range(0, n):
	ans = 1 / a[i]
	sum += ans
print(float(1 / sum))


n = int(input())
res = [1 / int(x) for x in input().split()]
print(1 / sum(res))


n = int(input())
a = [1 / int(e) for e in input().split()]
print(1 / sum(a))


n = int(input())
a = list(map(int, input().split()))
kei = 0.0
for i in range(n):
	kei += 1 / a[i]
print(float(1 / kei))


a = int(input())
f = list(map(int, input().split()))
bunbo = 0
for i in range(len(f)):
	bunbo += 1 / f[i]
print(1 / bunbo)


n = int(input())
print(1 / sum([1 / int(n) for n in input().split()]))


n = int(input())
A = list(map(int, input().split()))
ans = 0
for a in A:
	ans += 1 / a
print(1 / ans)


_ = input()
print(1 / sum([1 / r for r in list(map(int, input().split()))]))


import math
from functools import reduce

def lcm_base(x, y):
	return x * y // math.gcd(x, y)

def lcm(*a):
	return reduce(lcm_base, a, 1)

def lcm_list(a):
	return reduce(lcm_base, a, 1)
n = int(input())
a = list(map(int, input().split()))
mom = lcm_list(a)
a.sort()
num = []
for i in range(n):
	num.append(mom // a[i])
print(mom / sum(num))


N = int(input())
A = list(map(int, input().split()))
nom = 1
denom = A[0]
for i in range(1, N):
	nom = nom * A[i] + denom
	denom = denom * A[i]
print(denom / nom)


N = int(input())
A = list(map(int, input().split()))
lst = []
for i in A:
	lst.append(1 / i)
ans = 1 / sum(lst)
print(ans)


input()
A = list(map(int, input().split()))
B = [1 / a for a in A]
c = sum(B)
print(1 / c)


a = int(input())
b = list(map(int, input().split()))
c = 0
for i in range(a):
	c += 1 / b[i]
print(1 / c)


n = int(input())
A = list(map(int, input().split()))
total = 0
for i in range(n):
	total += 1 / A[i]
print(1 / total)


N = input()
A = list(map(float, input().split()))
print(1 / sum((1 / x for x in A)))


n = int(input())
arr = [1 / int(x) for x in input().split()]
print(1 / sum(arr))


(_, a) = open(0)
print(1 / sum((1 / int(i) for i in a.split())))


input()
revA = [1 / float(a) for a in input().split(' ')]
print(1 / sum(revA))


(N, A) = (input(), map(lambda x: 1 / int(x), input().split()))
print(1 / sum(A))


n = int(input())
a = [1 / int(s) for s in input().split()]
print(1 / sum(a))


n = int(input())
lst = [1 / int(i) for i in input().split()]
a = sum(lst)
print(1 / a)


def solve():
	N = int(input())
	A = list(map(int, input().split()))
	ans = 0
	A = [1 / a for a in A]
	print(1 / sum(A))
	return
solve()


from sys import stdin
n = int(stdin.readline().rstrip())
A = [int(a) for a in stdin.readline().rstrip().split()]
A = [float(a) for a in A]
total = 0.0
for a in A:
	total += 1 / a
print(1 / total)


n = int(input())
L = [1 / int(i) for i in input().split()]
print(1 / sum(L))


n = int(input())
li = list(map(int, input().split()))
li1 = []
for i in li:
	li1.append(1 / i)
su = sum(li1)
print(1 / su)


c = 0
a = input()
for i in input().split():
	c += 1 / int(i)
print(1 / c)


N = int(input())
out = 1 / sum([1 / int(a) for a in input().split()])
print(out)


input()
s = map(int, input().split())
ss = 0
for i in s:
	ss += 1 / i
print(1 / ss)


N = int(input())
A = map(int, input().split())
s = sum((1 / i for i in A))
t = 1 / s
print(t)


(n, a) = open(0)
print(1 / sum((1 / int(i) for i in a.split())))


n = int(input())
ans = 0
for i in input().split():
	ans += 1 / int(i)
print(1 / ans)


import numpy as np
N = int(input())
a = list(map(float, input().split()))
a_rev = np.reciprocal(a)
a_rev_sum = np.sum(a_rev)
print(1 / a_rev_sum)


N = int(input())
R = input().split(' ')
S = 0
for r in R:
	S += 1 / int(r)
print(1 / S)


d = input()
a = input().split()
r = 0
for i in a:
	r += 1 / int(i)
print(1 / r)


n = int(input())
a = list((1 / int(i) for i in input().split()))
print(1 / sum(a))


input()
A = input().split()
print(1 / sum((1 / int(a) for a in A)))


N = int(input())
A = list(map(int, input().split()))
bunbo = 0
for a in A:
	bunbo += 1 / a
print(1 / bunbo)


n = int(input())
l = map(int, input().split())
print(1 / sum([1 / x for x in l]))


N = int(input())
A = list(map(int, input().split()))
B = [1 / i for i in A]
Bs = sum(B)
ans = 1 / Bs
print(ans)


n = int(input())
lista = map(int, input().split())
b = sum((1 / i for i in lista))
print(1 / b)


N = input()
print(1 / sum([1 / a for a in map(int, input().strip().split(' '))]))


N = int(input())
An = 1 / sum([1 / int(A) for A in input().split()])
print(An)


N = int(input())
print(str(1 / sum((1 / int(i) for i in input().split(' ')))))


N = input()
ans = 1 / sum((1 / int(i) for i in input().split()))
print(ans)


N = int(input())
lsA = list(map(int, input().split()))
d = 0
for i in range(N):
	d += 1 / lsA[i]
print(1 / d)


N = int(input())
a = list((1 / int(i) for i in input().split()))
print(1 / sum(a))


n = int(input())
a_list = [1 / int(i) for i in input().split()]
ans = 1 / sum(a_list)
print(ans)


n = int(input())
a = list(map(int, input().strip().split()))
res = 0
for i in range(n):
	res += 1 / a[i]
res = 1 / res
print(res)


N = int(input())
A = [1 / int(n) for n in input().split()]
print(1 / sum(A))


N = int(input())
Alst = list(map(int, input().split()))
ans = 0
for i in Alst:
	ans += 1 / i
print(1 / ans)


N = int(input())
d = [int(s) for s in input().split()]
x = 1
for i in range(N):
	x = x * d[i]
y = 0
for i in range(N):
	y += int(x / d[i])
print(x / y)


(n, *A) = list(map(int, open(0).read().split()))
print(1 / sum([1 / a for a in A]))


n = int(input())
a = list(map(int, input().split()))
x = sum([1 / a[i] for i in range(n)])
print(1 / x)


x = int(input())
z = 0
for x in map(int, input().split()):
	z += 1 / x
print(1 / z)


N = int(input())
A = [1 / float(a) for a in input().split()]
n = sum(A)
print(1 / n)


n = input()
r = 0
for s in input().split():
	r += 1 / int(s)
print(1 / r)


input()
a = map(lambda a: 1 / int(a), input().split())
print(1 / sum(a))


N = int(input())
A = list(map(int, input().split()))
Arev = []
for a in A:
	Arev.append(1 / a)
print(1 / sum(Arev))


input()
A = list(map(int, input().strip().split(' ')))
print(1 / sum([1 / a for a in A]))


n = int(input())
v = list(map(int, input().split()))
print(1 / sum((1 / x for x in v)))