Integer square root integer approximate solution

zhaozj2021-02-12  140

The integer n begged an integer approximately square root R, so that R2 <= n <(R 1) 2

The input range is 0 --- 10 ^ 32 More than this range can be used as the same algorithm, and the integer solution is evaluated using high precision.

Input format

1

2

3

4

Output

1

1

1

2

#include #include using namespace std;

INT main () {char Num [1000]; INT I, J, Length; Double L, K; While (CIN >> NUM, STRCMP (NUM, "0")! = 0) {Length = Strlen (NUM); For (i = 0, k = 0.0, l = 0.0; i

|| Length% 2 == 0 && i% 2 == 1) {for (j = 0; j <11; j) {IF ((l * 20 j) * j> k) {--j; cout << j; k = k- (l * 20 j) * j; l * = 10; l = j; Break;}}}} cout << Endl;} return 0;}

转载请注明原文地址:https://www.9cbs.com/read-6842.html

New Post(0)