#include<bits/stdc++.h>
using namespace std;
struct a1
{
int x[100001];
a1()
{
memset(x,0,sizeof(x));
}
}x,y,z;
a1 operator - (const a1 a,const a1 b)
{
a1 c;
for(int q=1;q<=1201;q++)
{
c.x[q]=a.x[q]-b.x[q];
}
for(int q=1;q<=1201;q++)
{
if(c.x[q]<0)
{
c.x[q+1]--;
c.x[q]+=10;
}
}
return c;
}
void read()
{
string a;
cin>>a;
for(int q=1;q<=a.size();q++)z.x[q]=y.x[q]=x.x[q]=a[a.size()-q]-'0';
}
void print(a1 a)
{
int p=1021;
while(a.x[p]==0)p--;
for(int q=p;q>=1;q--)cout<<a.x[q];
}
int bi(a1 a,a1 b)
{
for(int q=1021;q>=1;q--)
{
if(a.x[q]>b.x[q])return 2;
if(a.x[q]<b.x[q])return 1;
}
return 0;
}
int main()
{
read();
int p=1201,l=0,k=0;
while(z.x[p]==0)p--;
for(int q=p-1;q>=1;q--)
{
if(z.x[q]%2==z.x[q+1]%2)
{
if(z.x[q]!=0&&k!=1)
{
k=1;
x.x[q]-=1;
for(int w=q-1;w>=1;w--)
{
if(x.x[w+1]%2==0)
{
x.x[w]=9;
}
else x.x[w]=8;
}
}
if(z.x[q]!=9&&l!=2)
{
l=2;
y.x[q]+=1;
for(int w=q-1;w>=1;w--)
{
if(y.x[w+1]%2==0)
{
y.x[w]=1;
}
else y.x[w]=0;
}
}
}
if(l==2&&k==1)break;
}
a1 x1=z-x,y1=y-z;
// print(x1);
if(bi(x1,y1)==1)print(y);
else if(bi(x1,y1)==2)print(x);
else if(bi(x,y)==0)print(x);
else
{
print(x);
cout<<" ";
print(y);
}
return 0;
}剪贴板
剪贴板 jf1np8qu
剪贴板信息
剪贴板信息
- 发布
- 收录
- 更新