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

WA9 ! what's wrong with my code !?! my code here
Posted by Farhad Ghasemi 19 Jun 2008 16:55
#include<iostream>
#include<math.h>
using namespace std;

int main()
{
    int n;
    int p;
    double a;
    int i;
    cin>>n;
    int flag;
     for(p=sqrt(n*2);p>0;p--)
     {
         a=(double)n/p-(double)(p-1)/2;
        if(a==(int)a && a>0)
        {
            cout<<a<<" "<<p;
            return 0;
        }

     }
    cout<<n<<" "<<1;
    return 0;
}
Re: WA9 ! what's wrong with my code !?! my code here
Posted by Nickolai Besschetnov 9 Oct 2008 14:37


Edited by author 09.10.2008 14:39
Re: WA9 ! what's wrong with my code !?! my code here
Posted by Denis Chertanov 15 Feb 2017 18:05
cout << (int)a << " " << p;
:)