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, n = 0, k = 0;
while(s > 0) {
if(s%10 == prev)return {n%(c/10) + 1, 1};
else if(s%10 == pprev)return {n%(c/100)+1, 1};
pprev = prev;
prev = s%10;
n+=s%10 * c;
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+=min(k.f, b-a + 1);
b-=k.f;
}
cout<<k - c+1;
}
Compilation message (stderr)
numbers.cpp: In function 'std::pair<long long int, bool> check(long long int)':
numbers.cpp:12:30: warning: unused variable 'k' [-Wunused-variable]
12 | long long c = 1, n = 0, k = 0;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |