Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- long long int magic(unsigned long long int c)
- {
- if(c<15)
- return 0;
- double C=(double)c,u,s,t,d=2*sqrt(C*C+1/27);
- long long n=0;
- if(d==0)
- u=-C,t=cbrt(u),s=cbrt(2*C-u);
- if(d>0)
- u=(-C+sqrt(C*C+1/27)),t=cbrt(u),s=cbrt(2*C+u);
- n=(long long int)(s-t);
- if(c==1ULL*(n*n*n+n)/2)
- return n;
- return 0;
- }
Add Comment
Please, Sign In to add comment