# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1120368 | Moonn | Palindrome-Free Numbers (BOI13_numbers) | C++17 | 1100 ms | 512 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define AI ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
ll a,b,s=0,z=0,i,j;
cin>>a>>b;
ll tt[19];
tt[0]=1;
for(i=1;i<19;i++)
tt[i]=tt[i-1]*10;
//cout<<a<<' '<<b<<endl;
while(a<=b)
{
// cout<<a<<' ';
string x=to_string(a);
ll z=0,eded=x[0]-'0';
bool bo=true;
for(i=1;i<x.size();i++)
{
if(x[i]==x[i-1])
{
bo=false;
z=x.size()-i-1;
j=i;
while(x[j]=='9')
{
j--;
z++;
eded/=10;
if(j==-1)
break;
}
if(j==-1)
eded=tt[z];
else
eded=eded*(tt[z+1])+(x[j]-'0'+1)*tt[z];
break;
}
if(i>1 and x[i]==x[i-2])
{
bo=false;
z=x.size()-i-1;
j=i;
while(x[j]=='9')
{
j--;
z++;
eded/=10;
if(j==-1)
break;
}
if(j==-1)
eded=tt[z];
else
eded=eded*(tt[z+1])+(x[j]-'0'+1)*tt[z];
break;
}
eded*=10;
eded+=x[i]-'0';
}
// cout<<eded<<"EDED ";
// if(bo)
// cout<<a<<' '<<s+1<<endl;
if(bo)
a=eded+1;
else
a=eded;
if(bo)
s++;
// cout<<s<<"say\n";
}
cout<<s<<endl;
}
/*
[
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |