#include <bits/stdc++.h>
#define pb push_back
#define s second
#define f first
#define ll long long
#define int ll
using namespace std;
int p[25];
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]*10;
int a,b,ans=0;
cin>>a>>b;
for (int i = a; i <= b; ){
int q=1,x=0,last = -1,last2 = -1;
for (int j = 18; j >= 0; j--){
if (i < p[j]) continue;
int y = (i/p[j])%10;
x = x*10 + y;
if (y == last || y == last2){
q=0;
x++;
x *= p[j];
break;
}
last2 = last;
last = y;
}
if (q) ans++,i++;
else i = x;
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
1 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 |
2 ms |
204 KB |
Output is correct |
16 |
Correct |
0 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 |
7 ms |
204 KB |
Output is correct |
20 |
Correct |
3 ms |
304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
153 ms |
324 KB |
Output is correct |
2 |
Execution timed out |
1086 ms |
204 KB |
Time limit exceeded |
3 |
Execution timed out |
1094 ms |
204 KB |
Time limit exceeded |
4 |
Execution timed out |
1091 ms |
204 KB |
Time limit exceeded |
5 |
Execution timed out |
1095 ms |
204 KB |
Time limit exceeded |
6 |
Execution timed out |
1081 ms |
204 KB |
Time limit exceeded |
7 |
Correct |
64 ms |
204 KB |
Output is correct |
8 |
Correct |
47 ms |
288 KB |
Output is correct |
9 |
Correct |
85 ms |
204 KB |
Output is correct |
10 |
Correct |
114 ms |
292 KB |
Output is correct |
11 |
Correct |
148 ms |
288 KB |
Output is correct |
12 |
Correct |
778 ms |
324 KB |
Output is correct |
13 |
Correct |
192 ms |
204 KB |
Output is correct |
14 |
Execution timed out |
1081 ms |
204 KB |
Time limit exceeded |
15 |
Execution timed out |
1093 ms |
204 KB |
Time limit exceeded |
16 |
Execution timed out |
1088 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 |
1091 ms |
204 KB |
Time limit exceeded |
22 |
Correct |
0 ms |
204 KB |
Output is correct |
23 |
Execution timed out |
1087 ms |
204 KB |
Time limit exceeded |
24 |
Correct |
0 ms |
204 KB |
Output is correct |
25 |
Execution timed out |
1095 ms |
204 KB |
Time limit exceeded |
26 |
Execution timed out |
1091 ms |
204 KB |
Time limit exceeded |
27 |
Execution timed out |
1093 ms |
204 KB |
Time limit exceeded |
28 |
Execution timed out |
1092 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 |
1078 ms |
204 KB |
Time limit exceeded |
32 |
Correct |
0 ms |
204 KB |
Output is correct |
33 |
Execution timed out |
1084 ms |
204 KB |
Time limit exceeded |
34 |
Correct |
1 ms |
204 KB |
Output is correct |
35 |
Execution timed out |
1089 ms |
204 KB |
Time limit exceeded |
36 |
Execution timed out |
1089 ms |
204 KB |
Time limit exceeded |
37 |
Execution timed out |
1096 ms |
204 KB |
Time limit exceeded |
38 |
Execution timed out |
1093 ms |
204 KB |
Time limit exceeded |
39 |
Execution timed out |
1098 ms |
204 KB |
Time limit exceeded |
40 |
Correct |
0 ms |
204 KB |
Output is correct |
41 |
Execution timed out |
1098 ms |
204 KB |
Time limit exceeded |
42 |
Correct |
0 ms |
204 KB |
Output is correct |
43 |
Execution timed out |
1091 ms |
204 KB |
Time limit exceeded |
44 |
Execution timed out |
1090 ms |
204 KB |
Time limit exceeded |
45 |
Execution timed out |
1096 ms |
204 KB |
Time limit exceeded |