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;
#define ll int
#define FORI(i, n) for(ll i = 0; i < n; i++)
#define FOR(i, n) for(ll i = 1; i <= n; i++)
typedef vector<ll> vl;
typedef set<ll> setl;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define pll pair<ll, ll>
#define db double
#define nll cout << "\n"
#define nl "\n"
#define sync ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
const ll mod = 1e9 + 7;
const int MAX = 300000 + 5;
const int imax = 2147483647;
ll n, m, k, res, rnk[MAX];
// ll a[MAX];
void solve(){
cin >> n >> m;
ll sz, f;
for(ll i = n; i <= m; i++){
string s = to_string(i);
sz = s.size();
if(s.size() == 1){
res++;
continue;
}
f = 1;
if(s[0] == s[1])continue;
for(ll j = 2; j < sz; j++){
if(s[j] == s[j - 1] || s[j] == s[j - 2]){
f = 0;
}
}
res += f;
}
cout << res;
}
signed main(){
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
sync;
ll t = 1;
// cin >> t;
FOR(i, t){
// cout << "Case #" << i << ": ";
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |