Test instructions: Given a number n, lets you find the nth number of N of the first digit.
Analysis: A look at this n fast to int limit, it is obvious can not do directly, to transform a bit. Since this is an index, we can take down the index.
That is, to take the logarithm, set ans = n ^ n, on both sides take 10 as the base logarithm of lg (ANS) = n * LG (10), and then this integer part is 10 multiple parties,
No use, that is to say we want the small number of parts, and then take the index, OK. Also note to use a long long because it may be super int, for the first time forget, WA.
The code is as follows:
#include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <queue > #include <cstring> #include <cmath>using namespace Std;typedef long long ll;int main () { int n, T; Cin >> T; while (t--) { cin >> N; Double ans = n * log10 (n); Ans-= (ll) ans;//decimal part cout << (LL) Pow (ten, ans) << Endl; } return 0;}
HDU 1060 leftmost Digit (math log)