An irrational decimal fraction is created by concatenating the positive integers:
0.123456789101112131415161718192021...
It can be seen that the 12th digit of the fractional part is 1.
If dn represents the nth digit of the fractional part, find the value of the following expression.
d1 × d10 × d100 × d1000 × d10000 × d100000 × d1000000
#include <iostream>
#include <string>
using namespace std;
string int_str(int a)
{
string res = "";
while (a)
{
char s = a % 10 + '0';
res = s + res;
a /= 10;
}
return res;
}
int main()
{
string s = "";
for (int i = 1; i <= 1000000; i++)
{
s = s + int_str(i);
}
int ans = 1;
ans = (s[1 - 1] - '0')*(s[10 - 1] - '0')*(s[100 - 1] - '0')*(s[1000 - 1] - '0')*(s[10000 - 1] - '0')*(s[100000 - 1] - '0')*(s[1000000 - 1] - '0');
cout << ans << endl;
system("pause");
return 0;
}