# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
796246 | duyanhloveav | Palindrome-Free Numbers (BOI13_numbers) | C++17 | 1096 ms | 320 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 9 + 1e6;
const long long oo = 7 + 1e18;
#pragma GCC optimize("Ofast,O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
long long pw[20];
string tostring(long long x) {
string s;
while (x > 0) {
s = s + (char)(x % 10 + '0');
x /= 10;
}
reverse(begin(s), end(s));
return s;
}
void SaKaTa() {
long long a, b;
cin >> a >> b;
pw[0] = 1;
for (int i = 1; i <= 18; i++) {
pw[i] = pw[i - 1] * 10;
}
long long ans = 0;
// check (s[i], s[i + 1]), (s[i], s[i + 2])
for (long long i = a; i <= b;) {
string s = tostring(i);
s = s + 's';
long long check = -oo;
for (int j = 0; j < s.size() - 2; j++) {
if (s[j] == s[j + 1]) {
check = s.size() - (j + 1) - 2;
break;
}
else if (s[j] == s[j + 2]) {
check = s.size() - (j + 2) - 2;
break;
}
}
if (check == -oo) {
++ans;
check = 0;
}
i = (i / pw[check] * pw[check]) + pw[check];
}
cout << ans;
}
int32_t main() {
#define TASKNAME "NPAL"
cin.tie(0)->sync_with_stdio(0);
if ( fopen( TASKNAME".inp", "r" ) ) {
freopen (TASKNAME".inp", "r", stdin);
freopen (TASKNAME".out", "w", stdout);
}
int testcase = 1;
// scanf("%d", &testcase);
while (testcase--)
SaKaTa();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |