#include <bits/stdc++.h>
#define pb push_back
#define s second
#define f first
#define ll long long
using namespace std;
ll p[25],x,last,last2,y;
bool q;
signed main (){
ios_base::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
p[0] = 1;
for (int i = 1; i <= 18; i++)
p[i] = p[i - 1]*10LL;
ll a,b,ans=0;
cin>>a>>b;
for (ll i = a; i <= b; ){
q = 1;
x=0; last = -1; last2 = -1;
for (int j = 18; j >= 0; j--){
if (i < p[j]) continue;
y = (i/p[j])%10;
x = x*10 + y;
if (y == last || y == last2){
q = 0;
x = (x + 1)*p[j];
break;
}
last2 = last;
last = y;
}
if (q == 1) ans++,i++;
else i = x;
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
7 ms |
204 KB |
Output is correct |
4 |
Correct |
3 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
2 ms |
204 KB |
Output is correct |
15 |
Correct |
3 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
6 ms |
204 KB |
Output is correct |
20 |
Correct |
3 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
152 ms |
288 KB |
Output is correct |
2 |
Execution timed out |
1099 ms |
204 KB |
Time limit exceeded |
3 |
Execution timed out |
1094 ms |
204 KB |
Time limit exceeded |
4 |
Execution timed out |
1100 ms |
204 KB |
Time limit exceeded |
5 |
Execution timed out |
1084 ms |
204 KB |
Time limit exceeded |
6 |
Execution timed out |
1093 ms |
204 KB |
Time limit exceeded |
7 |
Correct |
63 ms |
204 KB |
Output is correct |
8 |
Correct |
46 ms |
204 KB |
Output is correct |
9 |
Correct |
84 ms |
204 KB |
Output is correct |
10 |
Correct |
112 ms |
284 KB |
Output is correct |
11 |
Correct |
151 ms |
288 KB |
Output is correct |
12 |
Correct |
788 ms |
284 KB |
Output is correct |
13 |
Correct |
177 ms |
292 KB |
Output is correct |
14 |
Execution timed out |
1091 ms |
204 KB |
Time limit exceeded |
15 |
Execution timed out |
1097 ms |
204 KB |
Time limit exceeded |
16 |
Execution timed out |
1097 ms |
204 KB |
Time limit exceeded |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Execution timed out |
1089 ms |
204 KB |
Time limit exceeded |
22 |
Correct |
0 ms |
204 KB |
Output is correct |
23 |
Execution timed out |
1091 ms |
204 KB |
Time limit exceeded |
24 |
Correct |
0 ms |
204 KB |
Output is correct |
25 |
Execution timed out |
1089 ms |
204 KB |
Time limit exceeded |
26 |
Execution timed out |
1098 ms |
204 KB |
Time limit exceeded |
27 |
Execution timed out |
1091 ms |
204 KB |
Time limit exceeded |
28 |
Execution timed out |
1086 ms |
204 KB |
Time limit exceeded |
29 |
Correct |
0 ms |
204 KB |
Output is correct |
30 |
Correct |
0 ms |
204 KB |
Output is correct |
31 |
Execution timed out |
1094 ms |
204 KB |
Time limit exceeded |
32 |
Correct |
0 ms |
204 KB |
Output is correct |
33 |
Execution timed out |
1087 ms |
204 KB |
Time limit exceeded |
34 |
Correct |
0 ms |
204 KB |
Output is correct |
35 |
Execution timed out |
1091 ms |
204 KB |
Time limit exceeded |
36 |
Execution timed out |
1091 ms |
204 KB |
Time limit exceeded |
37 |
Execution timed out |
1091 ms |
204 KB |
Time limit exceeded |
38 |
Execution timed out |
1096 ms |
204 KB |
Time limit exceeded |
39 |
Execution timed out |
1086 ms |
204 KB |
Time limit exceeded |
40 |
Correct |
0 ms |
204 KB |
Output is correct |
41 |
Execution timed out |
1092 ms |
204 KB |
Time limit exceeded |
42 |
Correct |
0 ms |
204 KB |
Output is correct |
43 |
Execution timed out |
1098 ms |
204 KB |
Time limit exceeded |
44 |
Execution timed out |
1091 ms |
204 KB |
Time limit exceeded |
45 |
Execution timed out |
1088 ms |
204 KB |
Time limit exceeded |