|
|
back to boardwhich part may lead to overTime??? #include <iostream> #include <vector> using namespace std; inline double absValue(double x) { if(x>1e-6) return x; else return -x; } int main(int argc, char *argv[]) { unsigned long long int i; double sqrtTemp; vector<double> sqrtValue; sqrtValue.reserve(20000); while(cin >> i) { sqrtTemp = i/2; if(i) { do{ sqrtTemp = (sqrtTemp + i/sqrtTemp)/2 ; }while(absValue(sqrtTemp*sqrtTemp - i) > 1e-5); } sqrtValue.push_back(sqrtTemp); } vector<double>::reverse_iterator it,end; end = sqrtValue.rend(); for(it=sqrtValue.rbegin();it!=end;it++) { printf("%.4lf\n",*it); } system("pause"); return EXIT_SUCCESS; } Edited by author 08.03.2011 07:00 |
|
|