#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <bitset>
#include <iomanip>
#include <memory>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <climits>
#include <cassert>
using namespace std;
#define rep(i, x, y) for(int i = x; i <= y; ++i)
#define mp make_pair
#define add push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mem(a,b) memset(a, b, sizeof(a))
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:20000007")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair <int, int> pii;
typedef vector <int> lnum;
const int N = (int)1e6 + 100;
const int maxn = (int)1e3 + 100;
const int base = (int)1e9;
const int mod = (int)1e9 + 7;
const int inf = INT_MAX;
const long long ll_inf = LLONG_MAX;
const long double PI = acos((long double)-1.0);
const long double eps = 1e-8;
void solve() {
long long l, r; cin >> l >> r;
if (r - l > N) cout << (r - l) / 2 << '\n';
long long ans = 0;
for (long long i = l; i <= r; ++i) {
string now = to_string(i);
bool pal2, pal3;
pal2 = pal3 = 1;
if (now.size() >= 2) {
for (int j = 0; j < now.size() - 1; ++j) if (now[j] == now[j + 1]) {
pal2 = 0;
break;
}
}
if (now.size() >= 3) {
for (int j = 0; j < now.size() - 2; ++j) if (now[j] == now[j + 2]) {
pal3 = 0;
break;
}
}
ans += (pal2 & pal3);
}
cout << ans << '\n';
}
int main() {
//ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
//#define Freopen
#ifdef Freopen
#ifndef _MSC_VER
#define TASK ""
freopen(TASK".in", "r", stdin);
freopen(TASK".out", "w", stdout);
#endif
#endif
int T = 1;
//scanf("%d", &T);
for (; T; --T) solve();
#ifdef DEBUG
cerr << double(1.0 * clock() / CLOCKS_PER_SEC) << '\n';
#endif
return 0;
}
Compilation message
numbers.cpp:34:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(disable:4996)
numbers.cpp:35:0: warning: ignoring #pragma comment [-Wunknown-pragmas]
#pragma comment(linker, "/STACK:20000007")
numbers.cpp: In function 'void solve()':
numbers.cpp:63:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < now.size() - 1; ++j) if (now[j] == now[j + 1]) {
~~^~~~~~~~~~~~~~~~
numbers.cpp:69:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < now.size() - 2; ++j) if (now[j] == now[j + 2]) {
~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
21 ms |
428 KB |
Output is correct |
4 |
Correct |
12 ms |
440 KB |
Output is correct |
5 |
Correct |
2 ms |
452 KB |
Output is correct |
6 |
Correct |
2 ms |
456 KB |
Output is correct |
7 |
Correct |
2 ms |
480 KB |
Output is correct |
8 |
Correct |
2 ms |
520 KB |
Output is correct |
9 |
Correct |
2 ms |
520 KB |
Output is correct |
10 |
Correct |
2 ms |
520 KB |
Output is correct |
11 |
Correct |
2 ms |
520 KB |
Output is correct |
12 |
Correct |
2 ms |
520 KB |
Output is correct |
13 |
Correct |
2 ms |
596 KB |
Output is correct |
14 |
Correct |
13 ms |
596 KB |
Output is correct |
15 |
Correct |
13 ms |
596 KB |
Output is correct |
16 |
Correct |
2 ms |
596 KB |
Output is correct |
17 |
Correct |
5 ms |
596 KB |
Output is correct |
18 |
Correct |
2 ms |
596 KB |
Output is correct |
19 |
Correct |
22 ms |
596 KB |
Output is correct |
20 |
Correct |
12 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
814 ms |
604 KB |
Output isn't correct |
2 |
Execution timed out |
1080 ms |
604 KB |
Time limit exceeded |
3 |
Execution timed out |
1078 ms |
604 KB |
Time limit exceeded |
4 |
Execution timed out |
1071 ms |
604 KB |
Time limit exceeded |
5 |
Execution timed out |
1082 ms |
604 KB |
Time limit exceeded |
6 |
Execution timed out |
1084 ms |
604 KB |
Time limit exceeded |
7 |
Incorrect |
373 ms |
604 KB |
Output isn't correct |
8 |
Incorrect |
271 ms |
608 KB |
Output isn't correct |
9 |
Incorrect |
496 ms |
608 KB |
Output isn't correct |
10 |
Incorrect |
694 ms |
612 KB |
Output isn't correct |
11 |
Incorrect |
864 ms |
612 KB |
Output isn't correct |
12 |
Execution timed out |
1093 ms |
612 KB |
Time limit exceeded |
13 |
Execution timed out |
1083 ms |
612 KB |
Time limit exceeded |
14 |
Execution timed out |
1081 ms |
620 KB |
Time limit exceeded |
15 |
Execution timed out |
1077 ms |
620 KB |
Time limit exceeded |
16 |
Execution timed out |
1081 ms |
620 KB |
Time limit exceeded |
17 |
Execution timed out |
1085 ms |
620 KB |
Time limit exceeded |
18 |
Execution timed out |
1082 ms |
620 KB |
Time limit exceeded |
19 |
Execution timed out |
1081 ms |
620 KB |
Time limit exceeded |
20 |
Execution timed out |
1080 ms |
620 KB |
Time limit exceeded |
21 |
Execution timed out |
1079 ms |
620 KB |
Time limit exceeded |
22 |
Execution timed out |
1081 ms |
620 KB |
Time limit exceeded |
23 |
Execution timed out |
1076 ms |
620 KB |
Time limit exceeded |
24 |
Execution timed out |
1079 ms |
620 KB |
Time limit exceeded |
25 |
Execution timed out |
1089 ms |
620 KB |
Time limit exceeded |
26 |
Execution timed out |
1088 ms |
620 KB |
Time limit exceeded |
27 |
Execution timed out |
1085 ms |
620 KB |
Time limit exceeded |
28 |
Execution timed out |
1088 ms |
620 KB |
Time limit exceeded |
29 |
Execution timed out |
1081 ms |
620 KB |
Time limit exceeded |
30 |
Execution timed out |
1075 ms |
620 KB |
Time limit exceeded |
31 |
Execution timed out |
1087 ms |
620 KB |
Time limit exceeded |
32 |
Execution timed out |
1079 ms |
620 KB |
Time limit exceeded |
33 |
Execution timed out |
1076 ms |
620 KB |
Time limit exceeded |
34 |
Execution timed out |
1077 ms |
620 KB |
Time limit exceeded |
35 |
Execution timed out |
1078 ms |
620 KB |
Time limit exceeded |
36 |
Execution timed out |
1070 ms |
620 KB |
Time limit exceeded |
37 |
Execution timed out |
1087 ms |
620 KB |
Time limit exceeded |
38 |
Execution timed out |
1069 ms |
620 KB |
Time limit exceeded |
39 |
Execution timed out |
1080 ms |
620 KB |
Time limit exceeded |
40 |
Execution timed out |
1085 ms |
620 KB |
Time limit exceeded |
41 |
Execution timed out |
1083 ms |
620 KB |
Time limit exceeded |
42 |
Execution timed out |
1081 ms |
620 KB |
Time limit exceeded |
43 |
Execution timed out |
1088 ms |
620 KB |
Time limit exceeded |
44 |
Execution timed out |
1089 ms |
620 KB |
Time limit exceeded |
45 |
Execution timed out |
1083 ms |
620 KB |
Time limit exceeded |