optimizing
Time limit2sMemory limit1024 MB
Given n below 2^63, return the digit at index n (0-indexed) of the string formed by concatenating g(0), g(1), g(2), ... where g(k) is the sum of cubes below k.
- Level
Medium6 of 10
- Topics
- Math, Binary search, Implementation
- Solved
- No attempts yet
Statement
Write a function optimizing.
The input parameter is an int object n satisfying n . The return value is the int object , where is the following Python function:
def f(n):
assert type(n)==int and n>=0
g=lambda n:sum([x**3 for x in range(n)])
x=""
k=0
while n>=len(x):
x+=str(g(k))
k+=1
return int(x[n])