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;
long long nb(long long N)
{
long long mult = 1;
long long tot = 0;
int first = 0;
for (int i = 1; i < N; i *= 10)
{
if (N / i > 9 && (N / i) % 10 == (N / i / 10) % 10)
{
first = i;
}
if (N / i > 99 && (N / i) % 10 == (N / i / 100) % 10)
{
first = i;
}
}
if (first == 0)
tot++;
for (int i = first; N; i++)
{
int pos = N % 10;
if (N > 9 && (N / 10) % 10 < N % 10)
pos--;
if (N > 99 && (N / 100) % 10 < N % 10)
pos--;
tot += pos * mult;
N /= 10;
if (N > 9)
mult *= 8;
else
mult *= 9;
}
return tot;
}
int main()
{
long long a, b;
cin >> a >> b;
cout << nb(b) - nb(a - 1) << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |