ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1120. Sum of Sequential Numbers

Why Compliation Error??
Posted by Anne_Deb 5 Aug 2005 20:04
plz check my program...

#include<stdio.h>
#include<math.h>

int main()
{
    long n,a,p,x,chk=0,sum=0;
    scanf("%ld",&n);
    for(x=sqrt(n);chk==0;x++)
    {
        if(x*(x+1)/2>n)
        {
            break;
        }
    }
    for(chk=0;x<=n/2+1;x++)
    {
        for(p=1;sum<n;p++)
        {
            sum+=x+1-p;
            if(sum==n)
            {
                a=x+1-p;
                x=n/2+2;
                chk=1;
                break;
            }
        }
        sum=0;
    }
    if(chk==1) printf("%ld %ld",a,p);
    return 0;
}
Re: Why Compliation Error??
Posted by BillyDS 5 Aug 2005 20:44
Your source have some problem about sqrt fuction.
I think you have to use sqrt((double)n);