The main topic: given a 2^e prefix N, the number of bits of the known prefix n is less than half the number of bits of 2^e, find the minimum e that satisfies the condition.
Problem Analysis: Set 2^e as I digit, then have n*10^i<2^e< (n+1) *10^i. The solution inequalities are obtained I*LOG10 (n)/log10 (2) <e<i*log10 (n+1)/log10 (2). Starting with LOG10 (n) +2, I can be enumerated.
The code is as follows:
# include<iostream># include<cstdio># include<cmath># include<cstring># include<algorithm>using namespacestd;voidWork (unsigned n) {DoubleU= (Double) n; intI=LOG10 (U) +2; while(1){ intLow=floor (log2 (u) +i*log2 (Ten)); intHigh=ceil (log2 (u+1) +i*log2 (Ten)); if(high>low+1) {printf ("%d\n", low+1); return ; } ++i; }}intMain () {unsigned n; while(SCANF ("%u", &n)! =EOF) {work (n); } return 0;}
UVA-701 the Archeologists ' dilemma (number theory)