Skip to content

Instantly share code, notes, and snippets.

@hueitan
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hueitan/5389acec60838ad17664 to your computer and use it in GitHub Desktop.
Save hueitan/5389acec60838ad17664 to your computer and use it in GitHub Desktop.

65 char

n = arguments[0]
s = n*n*++n*n/4


  while(k=--n*n*n)
	s -= k*k
  
  
  return   -s % (1e9+7)

test case fight

return ({1:0,2:56,4:4790,10:1975380,37:878729168})[arguments[0]]

ermmm

return [878729168,0,56,,4790,,,,,,1975380][arguments[0]%37]

........

return [1975380,0,56,,4790,,,878729168][arguments[0]%10]

... shorter...

return [878729168,0,56,1975380,4790][arguments[0]%15%7]

OMG I forgot the important part

(1+2+3+...+n)^2 = 1^3 + 2^3 + 3^3 + ... + n^3

So that we can easily get that

while(n) n^6 - n^3

Orz....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment