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;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define f first
#define s second
#define DEBUG(a, b) cerr<<a<<b;
pair<long long, bool> check(long long s) {
long long prev = -1, pprev = -2;
long long c = 1;
while(s > 0) {
if(s%10 == prev)return {c/10, 1};
else if(s%10 == pprev)return {c/100, 1};
pprev = prev;
prev = s%10;
s/=10;
c*=10;
}
return {1, 0};
}
int main () {
long long a, b, c = 0;
cin >> a >> b;
long long k = b-a;
while(b >= a) {
pair<long long, bool> k = check(b);
if(k.s)c+=k.f;
b-=k.f;
}
cout<<k - c+1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |