# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
448461 | fuad27 | Palindrome-Free Numbers (BOI13_numbers) | C++14 | 1100 ms | 296 KiB |
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+=k.f;
b-=k.f;
}
cout<<k - c+1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |