forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path40.cpp
More file actions
58 lines (51 loc) · 952 Bytes
/
40.cpp
File metadata and controls
58 lines (51 loc) · 952 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
#include <sstream>
#include <cmath>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
typedef long long LL;
string i2s(int n) {
stringstream ss;
ss << n;
string res;
ss >> res;
return res;
}
LL s2ll(string str) {
stringstream ss;
ss << str;
LL res;
ss >> res;
return res;
}
int doit(int n) {
int m = 9;
for (int i = 1; ; ++i) {
if (n <= m * i) {
int b = m / 9;
int m = (n - 1) / i + b;
int d = n % i;
if (d == 0) d = i;
string s = i2s(m);
return s[d - 1] - '0';
}
n -= m * i;
m *= 10;
}
return 0;
}
void run() {
int res = 1;
int n = 1;
while (true) {
res *= doit(n);
n *= 10;
if (n > 1000000) break;
}
cout << res << endl;
}
int main() {
run();
return 0;
}