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 TLE ON TEST #9 MY COD IS SIMPLE
Posted by Лерник Казарян [RAU] 22 Feb 2014 21:26
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    long long n,p,a=1;
    cin>>n;
    while(1)
    {
        p=(1-2*a+sqrt((2*a-1)*(2*a-1)+8*n))/2;
        if(2*n==2*p*a+p*(p-1))
        {
            cout<<a<<" "<<p;
            break;
        }
        a++;
    }
    return 0;
}
Re: WHY TLE ON TEST #9 MY COD IS SIMPLE
Posted by ELDVN 14 Nov 2015 14:28
On test #9 my solution got the same problem.

Edited by author 14.11.2015 14:30