Created
June 16, 2015 09:16
-
-
Save zhrkvl/aa023888be2688d6f283 to your computer and use it in GitHub Desktop.
Bullshit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
withFile = 1 | |
if(withFile == 1): | |
fin = open('input.txt', 'r') | |
fout = open('output.txt', 'w') | |
def getl(): | |
if(withFile == 0): | |
return input() | |
else: | |
return fin.readline() | |
def printl(s): | |
if(withFile == 0): | |
print(s) | |
else: | |
fout.write(str(s)) | |
n = int(getl()) | |
ans = 0 | |
#x^3 + y^2 + z <= N | |
for x in range(1, 10**6): | |
# print(x) | |
yz = n - (x ** 3) | |
if(yz < 2): | |
break | |
l, r, y = 0, yz - 1, 0 | |
while(l <= r): | |
mid = int((l + r) / 2) | |
if(yz - (mid ** 2) == 1): | |
y = mid | |
break | |
if(yz - (mid ** 2) > 1): | |
l = mid + 1 | |
else: | |
y = r = mid - 1 | |
ans += y * yz - int(y*(y + 1)*(2*y + 1)/6) | |
printl(ans) | |
if(withFile == 1): | |
fin.close() | |
fout.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment