#include <iostream>
using namespace std;
int NthDigit( int n )
{
int nNumberLength = 1;
int nNumberCount = 9;
int nNumberBegin = 1;
while ( n > nNumberLength * nNumberCount )
{
n -= nNumberLength * nNumberCount;
nNumberLength += 1;
nNumberCount *= 10;
nNumberBegin *= 10;
}
int nIndex = (n - 1) / nNumberLength;
int nNumber = nNumberBegin + nIndex;
int times = (nNumberLength - 1) - ((n - 1) - nIndex * nNumberLength);
while ( times > 0 )
{
--times;
nNumber /= 10;
}
return nNumber % 10;
}
int main()
{
int result = 1;
result *= NthDigit( 1 );
result *= NthDigit( 10 );
result *= NthDigit( 100 );
result *= NthDigit( 1000 );
result *= NthDigit( 10000 );
result *= NthDigit( 100000 );
result *= NthDigit( 1000000 );
cout << result << endl;
return 0;
}
http://projecteuler.net/problem=40 [Answer:210]
最新推荐文章于 2023-11-15 12:12:51 发布