Basic ideas: (Refer to the great God and add their own thinking)
Considering that this problem needs to enter so large number A, and also to find a AA, to find out will be larger, more bits. At that time, consider using the large number method (array implementation), the result is not possible. Look at the online great god using the logarithmic method, cleverly avoid dealing with such a large number. This is the charm of mathematics!!
If aa=b, both sides take logarithm alog10a=log10b at the same time, thus have b=10alog10a. Now we focus on 10ALOG10A, first example: A number 2310, this number, replaced by 10c power, where the c=3. xxxxx. If rounding him up must be 3,103 is the maximum weight, then the remainder of the 100.xxxxx is the base of the highest position to be asked.
#include <iostream>#include<cmath>using namespacestd;intMain () {intN; CIN>>N; __int64 d,b;//int Type No DoubleA,c; while(n--) {unsignedLongm; CIN>>m; A=M*LOG10 (m*1.0);//alog10ab= (__int64) A;//take the wholeC=a-b;//0.xxxxxd= (__int64) POW (10.0, c);//10^0.xxxxx Roundingcout<<d<<Endl; } return 0;}
__int64:
64 is an integer type of data that has no definite specification. In today's mainstream compilers, support for the 64 integer is also standard and varies in form. In general, 64-bit integers are defined in long long and __int64 two (VC also supports _int64), while output to standard output is printf ("%lld", a), printf ("%i64d", a), and cout << A three different ways.
There are a few more:
- A long long definition can be used for gcc/g++, not platform-limited, but not for VC6.0.
- __int64 is the definition of the WIN32 platform compiler 64-bit long integer and cannot be used with Linux.
- "%lld" is used for the Linux i386 platform compiler, and "%i64d" is used for WIN32 platform compilers.
- Cout can only be used for C + + compilation, in VC6.0, the cout does not support 64-bit long integers.
For details, see: https://www.byvoid.com/blog/c-int64/
HDU 1060 Leftmost Digit