Skip to content

Instantly share code, notes, and snippets.

@hueitan

hueitan/^6-^2.md

Last active Aug 29, 2015
Embed
What would you like to do?

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
You can’t perform that action at this time.