-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path38.cpp
More file actions
36 lines (25 loc) · 689 Bytes
/
Copy path38.cpp
File metadata and controls
36 lines (25 loc) · 689 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
#include <algorithm>
#include <iostream>
#include <string>
int main() {
int best = 0;
for(int i = 9123; i <= 9487; i++) {
bool possible = true;
std::string res = std::to_string(i) + std::to_string(i * 2);
bool used[10];
std::fill_n(used, 10, false);
for(auto c : res) {
int digit = c - '0';
if(digit == 0 || used[digit]) {
possible = false;
break;
}
used[digit] = true;
}
if(!possible) continue;
int res_int = std::stoi(res);
best = std::max(best, res_int);
}
std::cout << best << '\n';
return 0;
}