forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path38.cpp
More file actions
61 lines (51 loc) · 923 Bytes
/
38.cpp
File metadata and controls
61 lines (51 loc) · 923 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
59
60
61
#include <iostream>
#include <sstream>
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;
}
LL res;
int mm[10];
void doit(int n) {
string s;
for (int i = 1; ; ++i) {
int t = n * i;
s += i2s(t);
if (s.length() >= 9) break;
}
if (s.length() > 9) return;
memset(mm, 0, sizeof(mm));
REP(i,9) {
int c = s[i] - '0';
if (c == 0) return;
if (mm[c] == 1) return;
mm[c] = 1;
}
LL m = s2ll(s);
res = max(res, m);
}
void run() {
FOR(i,1,9999) {
doit(i);
}
}
int main() {
res = 0;
run();
cout << res << endl;
return 0;
}