// author: Yusif_Nazarli
#pragma GCC optimize("O3")
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#define Mor_Te ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gcd __gcd
#define intt long long
#define pb push_back
#define emb emplace_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define F first
#define S second
#define pii pair<intt ,intt>
#define reset_map(m) for(auto &[k , v] : m) v = 0;
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using indexed_set = tree<T , null_type , less<T> , rb_tree_tag , tree_order_statistics_node_update>;
const intt sz = 1e5 + 5;
const intt INF = 1e18;
bool isPalindrome(const string &s){
int l = 0, r = s.size() - 1;
while(l < r){
if(s[l] != s[r]) return false;
l++;
r--;
}
return true;
}
bool ispolindromfree(string s){
for(intt i = 0; i < s.size(); i++){
string res = "";
for(intt j = i; j < s.size(); j++){
res += s[j];
if(res.size() > 1 && isPalindrome(res)){
return false;
}
}
}
return true;
}
void Yusiff(){
intt a , b; cin >> a >> b;
intt cnt = 0;
for(intt i = a; i <= b; i++){
string s = to_string(i);
if(ispolindromfree(s)) cnt++;
}
cout << cnt << '\n';
}
signed main(){
int t = 1;
//cin >> t;
for(intt i = 1; i <= t; i++){
// cout << "Case " << i << ": ";
Yusiff();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |