이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define s second
#define f first
#define ll long long
using namespace std;
ll p[25],x,last,last2,y;
bool q;
signed main (){
ios_base::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
p[0] = 1;
for (int i = 1; i <= 18; i++)
p[i] = p[i - 1]*10LL;
ll a,b,ans=0;
cin>>a>>b;
for (ll i = a; i <= b; ){
q = 1;
x=0; last = -1; last2 = -1;
for (int j = 18; j >= 0; j--){
if (i < p[j]) continue;
y = (i/p[j])%10;
x = x*10 + y;
if (y == last || y == last2){
q = 0;
x = (x + 1)*p[j];
break;
}
last2 = last;
last = y;
}
if (q == 1) ans++,i++;
else i = x;
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |