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;
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
bool has_palindrome(ll num){
string s = to_string(num);
ll n = s.size();
if (n == 1)
return 0;
if (n == 2){
if (s[0] == s[1])
return 1;
else
return 0;
}
if (s[0] == s[1])
return 1;
ll prev = s[0];
ll prevprev = s[1];
rep(i,2,n){
if (s[i] == prev){
return 1;
}
else
prev = s[i];
if (s[i] == prevprev){
return 1;
}
else
prevprev = s[i-1];
}
return 0;
}
ll calc(ll A, ll B){
ll cnt =0;
rep(i,A,B+1){
//cout << i << " " << has_palindrome(i) << "\n";
if (!has_palindrome(i))
cnt += 1;
}
return cnt;
}
int main(){
cin.tie(0)->sync_with_stdio(0);
ll A, B; cin >> A>> B;
cout << calc(A,B) << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |