|
|
back to boardwhy time limit on test#3? 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?? |
|
|