You are viewing a single comment's thread. Return to all comments →
I have no idea why i didn't pass all test case
import math R, n = input().split() R, n = int(R), int(n) rOld = sorted([int(i) for i in input().split(" ")]) if n == 1: res = 2*rOld[0] else: r = [] for i in range(len(rOld)): if i % 2 == 0: r.append(rOld[i]) else: r = [rOld[i]] + r res = r[0] + r[-1] for i in range(n-1): res += math.sqrt((r[i]+r[i+1])**2 - (2*R-(r[i]+r[i+1]))**2) print(round(res*1000))
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #222: Sphere Packing
You are viewing a single comment's thread. Return to all comments →
I have no idea why i didn't pass all test case