#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;
long long ans = 0;
for (int i = l; i <= r; ++i) {
string now = to_string(i);
bool pal2, pal3;
pal2 = pal3 = 1;
for (int i = 0; i < now.size() - 1; ++i) if (now[i] == now[i + 1]) {
pal2 = 0;
break;
}
for (int i = 0; i < now.size() - 2; ++i) if (now[i] == now[i + 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:61:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < now.size() - 1; ++i) if (now[i] == now[i + 1]) {
~~^~~~~~~~~~~~~~~~
numbers.cpp:65:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < now.size() - 2; ++i) if (now[i] == now[i + 2]) {
~~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
496 KB |
Output isn't correct |
3 |
Execution timed out |
1076 ms |
524 KB |
Time limit exceeded |
4 |
Incorrect |
13 ms |
524 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
524 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
540 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
548 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
548 KB |
Output isn't correct |
9 |
Correct |
2 ms |
556 KB |
Output is correct |
10 |
Correct |
2 ms |
556 KB |
Output is correct |
11 |
Correct |
3 ms |
556 KB |
Output is correct |
12 |
Correct |
2 ms |
628 KB |
Output is correct |
13 |
Correct |
2 ms |
628 KB |
Output is correct |
14 |
Incorrect |
13 ms |
632 KB |
Output isn't correct |
15 |
Incorrect |
13 ms |
680 KB |
Output isn't correct |
16 |
Correct |
2 ms |
680 KB |
Output is correct |
17 |
Correct |
6 ms |
680 KB |
Output is correct |
18 |
Incorrect |
2 ms |
680 KB |
Output isn't correct |
19 |
Execution timed out |
1076 ms |
696 KB |
Time limit exceeded |
20 |
Correct |
13 ms |
728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
857 ms |
784 KB |
Output is correct |
2 |
Execution timed out |
1083 ms |
812 KB |
Time limit exceeded |
3 |
Execution timed out |
1091 ms |
812 KB |
Time limit exceeded |
4 |
Execution timed out |
1085 ms |
812 KB |
Time limit exceeded |
5 |
Execution timed out |
1084 ms |
812 KB |
Time limit exceeded |
6 |
Execution timed out |
1068 ms |
812 KB |
Time limit exceeded |
7 |
Correct |
403 ms |
824 KB |
Output is correct |
8 |
Correct |
316 ms |
832 KB |
Output is correct |
9 |
Correct |
537 ms |
848 KB |
Output is correct |
10 |
Correct |
711 ms |
852 KB |
Output is correct |
11 |
Correct |
887 ms |
852 KB |
Output is correct |
12 |
Execution timed out |
1085 ms |
860 KB |
Time limit exceeded |
13 |
Execution timed out |
1086 ms |
860 KB |
Time limit exceeded |
14 |
Execution timed out |
1084 ms |
860 KB |
Time limit exceeded |
15 |
Execution timed out |
1074 ms |
860 KB |
Time limit exceeded |
16 |
Execution timed out |
1087 ms |
860 KB |
Time limit exceeded |
17 |
Execution timed out |
1074 ms |
860 KB |
Time limit exceeded |
18 |
Execution timed out |
1074 ms |
860 KB |
Time limit exceeded |
19 |
Execution timed out |
1085 ms |
860 KB |
Time limit exceeded |
20 |
Execution timed out |
1089 ms |
860 KB |
Time limit exceeded |
21 |
Execution timed out |
1083 ms |
860 KB |
Time limit exceeded |
22 |
Execution timed out |
1075 ms |
860 KB |
Time limit exceeded |
23 |
Execution timed out |
1078 ms |
860 KB |
Time limit exceeded |
24 |
Execution timed out |
1064 ms |
860 KB |
Time limit exceeded |
25 |
Execution timed out |
1093 ms |
860 KB |
Time limit exceeded |
26 |
Execution timed out |
1076 ms |
860 KB |
Time limit exceeded |
27 |
Execution timed out |
1084 ms |
860 KB |
Time limit exceeded |
28 |
Execution timed out |
1085 ms |
860 KB |
Time limit exceeded |
29 |
Execution timed out |
1075 ms |
860 KB |
Time limit exceeded |
30 |
Execution timed out |
1067 ms |
860 KB |
Time limit exceeded |
31 |
Execution timed out |
1068 ms |
860 KB |
Time limit exceeded |
32 |
Execution timed out |
1083 ms |
860 KB |
Time limit exceeded |
33 |
Execution timed out |
1081 ms |
860 KB |
Time limit exceeded |
34 |
Execution timed out |
1080 ms |
860 KB |
Time limit exceeded |
35 |
Execution timed out |
1086 ms |
860 KB |
Time limit exceeded |
36 |
Execution timed out |
1083 ms |
860 KB |
Time limit exceeded |
37 |
Execution timed out |
1068 ms |
860 KB |
Time limit exceeded |
38 |
Execution timed out |
1083 ms |
860 KB |
Time limit exceeded |
39 |
Execution timed out |
1084 ms |
860 KB |
Time limit exceeded |
40 |
Execution timed out |
1083 ms |
976 KB |
Time limit exceeded |
41 |
Execution timed out |
1080 ms |
976 KB |
Time limit exceeded |
42 |
Execution timed out |
1079 ms |
976 KB |
Time limit exceeded |
43 |
Execution timed out |
1079 ms |
976 KB |
Time limit exceeded |
44 |
Execution timed out |
1072 ms |
976 KB |
Time limit exceeded |
45 |
Execution timed out |
1089 ms |
976 KB |
Time limit exceeded |