#include <bits/stdc++.h>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
//#define int long long
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,bmi,bmi2,lzcnt,popcnt")
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;
const double eps = 1e-9;
int32_t main() {
ios_base::sync_with_stdio(false);
cout.tie(0); cin.tie(0);
ll a, b, ans=0;
cin >> a >> b;
for(ll i=a; i<=b; i++) {
bool ok = 1;
string s = to_string(i);
for(int j=0; j+1<s.size(); j++) {
if(s[j] == s[j+1]) ok = 0;
if(j+2 < s.size() && s[j] == s[j+2]) ok = 0;
}
ans += ok;
}
cout << ans << '\n';
return 0;
}
Compilation message
numbers.cpp: In function 'int32_t main()':
numbers.cpp:34:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for(int j=0; j+1<s.size(); j++) {
| ~~~^~~~~~~~~
numbers.cpp:36:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | if(j+2 < s.size() && s[j] == s[j+2]) ok = 0;
| ~~~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
5 ms |
448 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
5 ms |
448 KB |
Output is correct |
20 |
Correct |
2 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
1029 ms |
344 KB |
Time limit exceeded |
3 |
Execution timed out |
1057 ms |
348 KB |
Time limit exceeded |
4 |
Execution timed out |
1072 ms |
348 KB |
Time limit exceeded |
5 |
Execution timed out |
1041 ms |
344 KB |
Time limit exceeded |
6 |
Execution timed out |
1064 ms |
348 KB |
Time limit exceeded |
7 |
Correct |
51 ms |
348 KB |
Output is correct |
8 |
Correct |
36 ms |
444 KB |
Output is correct |
9 |
Correct |
65 ms |
428 KB |
Output is correct |
10 |
Correct |
93 ms |
544 KB |
Output is correct |
11 |
Correct |
137 ms |
344 KB |
Output is correct |
12 |
Correct |
736 ms |
424 KB |
Output is correct |
13 |
Correct |
146 ms |
348 KB |
Output is correct |
14 |
Execution timed out |
1054 ms |
344 KB |
Time limit exceeded |
15 |
Execution timed out |
1039 ms |
344 KB |
Time limit exceeded |
16 |
Execution timed out |
1063 ms |
348 KB |
Time limit exceeded |
17 |
Execution timed out |
1037 ms |
348 KB |
Time limit exceeded |
18 |
Execution timed out |
1059 ms |
348 KB |
Time limit exceeded |
19 |
Execution timed out |
1062 ms |
348 KB |
Time limit exceeded |
20 |
Execution timed out |
1029 ms |
344 KB |
Time limit exceeded |
21 |
Execution timed out |
1061 ms |
348 KB |
Time limit exceeded |
22 |
Execution timed out |
1035 ms |
344 KB |
Time limit exceeded |
23 |
Execution timed out |
1063 ms |
348 KB |
Time limit exceeded |
24 |
Execution timed out |
1039 ms |
344 KB |
Time limit exceeded |
25 |
Execution timed out |
1040 ms |
348 KB |
Time limit exceeded |
26 |
Execution timed out |
1025 ms |
344 KB |
Time limit exceeded |
27 |
Execution timed out |
1042 ms |
344 KB |
Time limit exceeded |
28 |
Execution timed out |
1028 ms |
344 KB |
Time limit exceeded |
29 |
Execution timed out |
1033 ms |
344 KB |
Time limit exceeded |
30 |
Execution timed out |
1055 ms |
348 KB |
Time limit exceeded |
31 |
Execution timed out |
1034 ms |
344 KB |
Time limit exceeded |
32 |
Execution timed out |
1078 ms |
348 KB |
Time limit exceeded |
33 |
Execution timed out |
1042 ms |
344 KB |
Time limit exceeded |
34 |
Execution timed out |
1036 ms |
344 KB |
Time limit exceeded |
35 |
Execution timed out |
1056 ms |
348 KB |
Time limit exceeded |
36 |
Execution timed out |
1056 ms |
348 KB |
Time limit exceeded |
37 |
Execution timed out |
1062 ms |
348 KB |
Time limit exceeded |
38 |
Execution timed out |
1044 ms |
348 KB |
Time limit exceeded |
39 |
Execution timed out |
1069 ms |
348 KB |
Time limit exceeded |
40 |
Execution timed out |
1027 ms |
344 KB |
Time limit exceeded |
41 |
Execution timed out |
1008 ms |
600 KB |
Time limit exceeded |
42 |
Execution timed out |
1024 ms |
344 KB |
Time limit exceeded |
43 |
Execution timed out |
1041 ms |
344 KB |
Time limit exceeded |
44 |
Execution timed out |
1053 ms |
344 KB |
Time limit exceeded |
45 |
Execution timed out |
1046 ms |
348 KB |
Time limit exceeded |