-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem 40
More file actions
30 lines (25 loc) · 751 Bytes
/
Copy pathproblem 40
File metadata and controls
30 lines (25 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*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;
int main() {
string whole_numbers = "123456789";
for(int i = 1; i < 1000000; i++){
for(int j = 0; j < 10; j++){
whole_numbers += to_string(i) + to_string(j);
}
}
int product = 1;
int k = 9;
while(k < 1000000){
product *= int(whole_numbers[k]) - '0';
k = k * 10 + 9;
}
cout << product <<endl;
return 0;
}