SHARE
TWEET

PatratMagic4

a53 Jan 22nd, 2020 (edited) 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cmath>
  2. long long int magic(unsigned long long int c)
  3. {
  4.     if(c<15)
  5.         return 0;
  6.     double C=(double)c,u,s,t,d=2*sqrt(C*C+1/27);
  7.     long long n=0;
  8.     if(d==0)
  9.         u=-C,t=cbrt(u),s=cbrt(2*C-u);
  10.     if(d>0)
  11.         u=(-C+sqrt(C*C+1/27)),t=cbrt(u),s=cbrt(2*C+u);
  12.     n=(long long int)(s-t);
  13.     if(c==1ULL*(n*n*n+n)/2)
  14.         return n;
  15.     return 0;
  16. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top