Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cmath>
- using namespace std;
- int main() {
- long long int a,b,c,i,j,m,n1,num,found;
- double n,det;
- while (scanf("%lld",&num)) {
- if (num<0) break;
- found = 0;
- a=num;
- b=num;
- c = (num/2) +1;
- for (m=0;m<=c&&!found;m++) {
- det = sqrt(1+4*(m*m+m+2*num));
- n = (-1+det)/2;
- n1 = n;
- if (n1==n) {
- found =1;
- a = n;
- b = 1+m;
- }
- }
- printf("%lld = %lld + ... + %lld\n",num,b,a);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment