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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define run ios_base::sync_with_stdio(false);cin.tie(0);
#define ll int
#define pll pair<ll, ll>
#define ull unsigned ll
#define ld double
#define endl "\n"
#define pb push_back
#define fi first
#define se second
#define pi acos(-1)
#define N 100007
#define minimum -9223372036854775807
#define maximum -minimum
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;
template <class t>
using ordered_set=tree<t, null_type,less_equal<t>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll gcd(ll a, ll b)
{
if(b==0)
return a;
return gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
return a/gcd(a, b)*b;
}
bool isprime(ll n)
{
if(n==1)
return 0;
for(ll i=2; i*i<=n; i++)
{
if(n%i==0)
return 0;
}
return 1;
}
ll binpow(ll a, ll b)
{
a%=mod;
ll res=1;
while(b>0)
{
if(b%2==1)
res=(res*a)%mod;
a=(a*a)%mod;
b/=2;
}
return res;
}
int main()
{
run;
ll a, b;
cin>>a>>b;
ll cvb=0;
for(ll i=a; i<=b; i++)
{
string s=to_string(i);
// cout<<s<<" ";
if(s.length()<=2)
{
if(s.length()==1)
continue;
if(s[0]!=s[1])
cvb++;
continue;
}
map<char, vector<ll>>mp;
for(ll j=0; j<s.length(); j++)
{
mp[s[j]].pb(j);
}
bool bul=1;
for(auto j:mp)
{
for(ll k=0; k<j.second.size(); k++)
{
for(ll kk=k+1; kk<j.second.size(); kk++)
{
string x=s.substr(j.second[k], j.second[kk]-j.second[k]+1);
// cout<<x<<" ";
string revx=x;
reverse(revx.begin(), revx.end());
if(revx==x)
{
bul=0;
break;
}
}
}
if(!bul)
break;
}
if(bul)
cvb++;
// cout<<endl;
}
cout<<cvb<<endl;
}
// By Xanlar
Compilation message (stderr)
numbers.cpp: In function 'int main()':
numbers.cpp:85:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
85 | for(ll j=0; j<s.length(); j++)
| ~^~~~~~~~~~~
numbers.cpp:92:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
92 | for(ll k=0; k<j.second.size(); k++)
| ~^~~~~~~~~~~~~~~~
numbers.cpp:94:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
94 | for(ll kk=k+1; kk<j.second.size(); kk++)
| ~~^~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |