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 1705. Gangster Hares

why time limit on test#3?
Posted by lolpwnZzzz 22 Nov 2010 00:06
my code:

// 1705.cpp : Defines the entry point for the console application.
//

#include <iostream>
using namespace std;
double sqroot(double);
int main()
{
    int t;
    cin>>t;
    long long int input[50001];
    long long int output[50001];
    for(int i=0;i<t;i++)
    {
        scanf("%lli",&input[i]);
        long long int k=2;
        k=sqroot((double)input[i]);
        if(k<1) k = 1;
        while(true )
        {
            if(input[i]/k==(input[i]/(k+1)))
                break;
            else
                k++;
        }
        output[i]=k;
    }
    for(int i=0;i<t;i++)
        printf("%lli\n",output[i]);
    return 0;
}

inline double sqroot(double n)
{
    double begin=0;
    double end=n;
    double res=0;
    double precision=0.1;
    while(end-begin>precision)
    {
        res=(begin+end)/2;
        if(res*res>n)
            end=res;
        else
            begin=res;
    }
    return res;
}
for n=10^18 loop execute about 30000 times
May this be the couse of time limit??