-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path112.cpp
More file actions
42 lines (39 loc) · 885 Bytes
/
112.cpp
File metadata and controls
42 lines (39 loc) · 885 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
#include <iostream>
#include <sstream>
bool check(int x) {
std::stringstream ss;
ss << x;
std::string s = ss.str();
bool isIncreasing = true;
for (int i = 1; i < s.size(); ++i) {
if (s[i] < s[i - 1]) {
isIncreasing = false;
break;
}
}
bool isDecreasing = true;
for (int i = 1; i < s.size(); ++i) {
if (s[i] > s[i - 1]) {
isDecreasing = false;
break;
}
}
return !isIncreasing && !isDecreasing;
}
int main() {
long long cnt = 0;
for (long long i = 101; i < 2000'000'000; ++i) {
if (check(i)) {
++cnt;
// std::cout << i << " " << cnt << std::endl;
}
if (i * 99 / 100 == cnt && cnt * 100 / 99 == i) {
std::cout << i << " " << cnt << std::endl;
return 0;
}
if (i * 90 / 100 == cnt && cnt * 100 / 90 == i) {
std::cout << i << " " << cnt << std::endl;
}
}
return 0;
}