#include <bits/stdc++.h>
#define loop(a, b) for(int a = 0; a < b; ++a)
#define loop1(a, b) for(int a = 1; a <= b; ++a)
#define loopc(a, c, b) for(unsigned long long a = c; a <= b; ++a)
#define loopr(a, b) for(int a = b-1; a >= 0; --a)
#define mp make_pair
using namespace std;
typedef unsigned long long ull;
deque<int> aa, bb;
ull ai, bi, p, av=0, bv=0, v;
set<int> pos;
int prev=-1, prev2=-1, as, bs;
bool af=false, bf=false;
int main() {
cin >> ai >> bi;
/*++bi;
while(ai) {
aa.push_front(ai%10);
ai /= 10;
}
while(bi) {
bb.push_front(bi%10);
bi /= 10;
}
//loop(a, 10) pos.insert(a);
as = aa.size();
loop(a, as) {
if (a == 0) {
loop(h, as) {
if (h == 0) {
v = aa[0]-1;
if (as > 1) v *= 9;
loopc(w, 2, as) v *= 8;
av = v;
}
else if (h == as-1) av += 10;
else {
v = 9;
if (as > h+1) v *= 9;
loopc(w, h+2, as) v *= 8;
av += v;
}
//cout << av << endl;
}
}
else {
v = aa[a] - (int)(aa[a] > aa[a-1]);
if (a > 1 && aa[a-1] != aa[a-2]) v -= (int)(aa[a] > aa[a-2]);
loopc(w, a+1, as) v *= 8;
av += v;
if (aa[a] == aa[a-1]) break;
if (a > 1 && aa[a] == aa[a-2]) break;
}
//cout << a << " " <<av << endl;
}
bs = bb.size();
loop(b, bs) {
//cout << bb[b] << " bb"<< endl;
if (b == 0) {
loop(h, bs) {
if (h == 0) {
v = bb[0]-1;
if (bs > 1) v *= 9;
loopc(w, 2, bs) v *= 8;
bv = v;
}
else if (h == bs-1) bv += 10;
else {
v = 9;
if (bs > h+1) v *= 9;
loopc(w, h+2, bs) v *= 8;
bv += v;
}
//cout << bv << endl;
}
}
else {
v = bb[b] - (int)(bb[b] > bb[b-1]);
if (b > 1 && bb[b-1] != bb[b-2]) v -= (int)(bb[b] > bb[b-2]);
loopc(w, b+1, bs) v *= 8;
bv += v;
//cout << v << " v" << endl;
if (bb[b] == bb[b-1]) break;
if (b > 1 && bb[b] == bb[b-2]) break;
}
//cout << b << " " << bv << endl;
}
cout << bv - av << endl;*/
int t, tot=0;
loopc(a, ai, bi) {
t = 1;
v = a;
while(v) {
aa.push_front(v%10);
v /= 10;
}
if (aa.size() > 0) {
loop(b, aa.size()-1) {
if (aa[b] == aa[b+1]) t = 0;
}
}
if (aa.size() > 1) {
loop(b, aa.size()-2) {
if (aa[b] == aa[b+2]) t = 0;
}
}
tot += t;
aa.clear();
}
cout << tot << endl;
return 0;
}
Compilation message
numbers.cpp: In function 'int main()':
numbers.cpp:2:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
2 | #define loop(a, b) for(int a = 0; a < b; ++a)
......
111 | loop(b, aa.size()-1) {
| ~~~~~~~~~~~~~~
numbers.cpp:111:13: note: in expansion of macro 'loop'
111 | loop(b, aa.size()-1) {
| ^~~~
numbers.cpp:2:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
2 | #define loop(a, b) for(int a = 0; a < b; ++a)
......
116 | loop(b, aa.size()-2) {
| ~~~~~~~~~~~~~~
numbers.cpp:116:13: note: in expansion of macro 'loop'
116 | loop(b, aa.size()-2) {
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
14 ms |
256 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
0 ms |
256 KB |
Output is correct |
10 |
Correct |
0 ms |
256 KB |
Output is correct |
11 |
Correct |
0 ms |
256 KB |
Output is correct |
12 |
Correct |
1 ms |
288 KB |
Output is correct |
13 |
Correct |
0 ms |
256 KB |
Output is correct |
14 |
Correct |
5 ms |
256 KB |
Output is correct |
15 |
Correct |
4 ms |
256 KB |
Output is correct |
16 |
Correct |
1 ms |
256 KB |
Output is correct |
17 |
Correct |
3 ms |
256 KB |
Output is correct |
18 |
Correct |
0 ms |
256 KB |
Output is correct |
19 |
Correct |
15 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
548 ms |
256 KB |
Output is correct |
2 |
Execution timed out |
1080 ms |
256 KB |
Time limit exceeded |
3 |
Execution timed out |
1080 ms |
256 KB |
Time limit exceeded |
4 |
Execution timed out |
1086 ms |
256 KB |
Time limit exceeded |
5 |
Execution timed out |
1084 ms |
256 KB |
Time limit exceeded |
6 |
Execution timed out |
1091 ms |
256 KB |
Time limit exceeded |
7 |
Correct |
186 ms |
376 KB |
Output is correct |
8 |
Correct |
132 ms |
256 KB |
Output is correct |
9 |
Correct |
242 ms |
256 KB |
Output is correct |
10 |
Correct |
361 ms |
380 KB |
Output is correct |
11 |
Correct |
539 ms |
368 KB |
Output is correct |
12 |
Execution timed out |
1083 ms |
256 KB |
Time limit exceeded |
13 |
Correct |
568 ms |
364 KB |
Output is correct |
14 |
Execution timed out |
1084 ms |
256 KB |
Time limit exceeded |
15 |
Execution timed out |
1089 ms |
256 KB |
Time limit exceeded |
16 |
Execution timed out |
1096 ms |
256 KB |
Time limit exceeded |
17 |
Execution timed out |
1083 ms |
256 KB |
Time limit exceeded |
18 |
Execution timed out |
1074 ms |
256 KB |
Time limit exceeded |
19 |
Execution timed out |
1083 ms |
256 KB |
Time limit exceeded |
20 |
Execution timed out |
1084 ms |
256 KB |
Time limit exceeded |
21 |
Execution timed out |
1086 ms |
256 KB |
Time limit exceeded |
22 |
Execution timed out |
1085 ms |
288 KB |
Time limit exceeded |
23 |
Execution timed out |
1096 ms |
256 KB |
Time limit exceeded |
24 |
Execution timed out |
1096 ms |
256 KB |
Time limit exceeded |
25 |
Execution timed out |
1093 ms |
256 KB |
Time limit exceeded |
26 |
Execution timed out |
1094 ms |
256 KB |
Time limit exceeded |
27 |
Execution timed out |
1087 ms |
256 KB |
Time limit exceeded |
28 |
Execution timed out |
1083 ms |
256 KB |
Time limit exceeded |
29 |
Execution timed out |
1099 ms |
256 KB |
Time limit exceeded |
30 |
Execution timed out |
1099 ms |
256 KB |
Time limit exceeded |
31 |
Execution timed out |
1084 ms |
256 KB |
Time limit exceeded |
32 |
Execution timed out |
1097 ms |
256 KB |
Time limit exceeded |
33 |
Execution timed out |
1100 ms |
256 KB |
Time limit exceeded |
34 |
Execution timed out |
1099 ms |
256 KB |
Time limit exceeded |
35 |
Execution timed out |
1089 ms |
256 KB |
Time limit exceeded |
36 |
Execution timed out |
1100 ms |
256 KB |
Time limit exceeded |
37 |
Execution timed out |
1099 ms |
256 KB |
Time limit exceeded |
38 |
Execution timed out |
1092 ms |
256 KB |
Time limit exceeded |
39 |
Execution timed out |
1094 ms |
256 KB |
Time limit exceeded |
40 |
Execution timed out |
1091 ms |
256 KB |
Time limit exceeded |
41 |
Execution timed out |
1087 ms |
256 KB |
Time limit exceeded |
42 |
Execution timed out |
1036 ms |
256 KB |
Time limit exceeded |
43 |
Execution timed out |
1076 ms |
256 KB |
Time limit exceeded |
44 |
Execution timed out |
1088 ms |
256 KB |
Time limit exceeded |
45 |
Execution timed out |
1083 ms |
256 KB |
Time limit exceeded |