Submission #448556

#TimeUsernameProblemLanguageResultExecution timeMemory
448556BT21tataPalindrome-Free Numbers (BOI13_numbers)C++17
34.17 / 100
1096 ms308 KiB
#include<bits/stdc++.h> #pragma GCC target ("avx,avx2,fma") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") typedef long long ll; typedef long double ld; #define SPEED ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0) #define rall(v) (v).rbegin(),(v).rend() #define all(v) (v).begin(),(v).end() #define OK cerr<<"OK"<<endl<<flush #define pii pair<int, int> #define pll pair<ll, ll> #define pb push_back #define F first #define S second #define y0 jahdakdh #define y1 jahsadakdakdh #define endl '\n' using namespace std; const ll MOD=1e9+7; // mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count()); ll a, b, p[20]; ll ans; int check(ll x) { string s=to_string(x); int n=s.length(); s+='-'; for(int i=0; i<n-1; i++) { if(s[i]==s[i+1]) return n-(i+1)-1; else if(s[i]==s[i+2]) return n-(i+2)-1; } return -1; } int main() { SPEED; p[0]=1; for(int i=1; i<=18; i++) p[i]=p[i-1]*10; cin>>a>>b; for(int i=a; i<=b;) { int e=check(i); if(e==-1) ans++, e++; //cout<<i<<' '<<e<<endl; i=(i/p[e]*p[e])+p[e]; } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...