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;
bool isPalindrome(const string &str) {
string s1 = str.substr(0, str.size() / 2 + str.size() % 2);
string s2 = str.substr(str.size() / 2);
reverse(s2.begin(), s2.end());
return s1 == s2;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int a, b, ans = 0;
cin >> a >> b;
for (int i = a; i <= b; i++) {
string str = to_string(i);
char ok = true;
for (size_t i = 0; i < str.size(); i++) {
for (size_t j = 2; j <= str.size() - i; j++) {
string substr = str.substr(i, j);
if (isPalindrome(substr)) {
ok = false;
break;
}
}
if (!ok) {
break;
}
}
if (ok) {
ans++;
}
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |