富学识 博闻广记
源心性 静雅润和
//i yy;
//o yy
//s xx yy
//t yy yy
//+
//-
//*
///
//%
//: xxxx
//>
//<
//=
//g
string operator +(string x,string y)
{
string z;
int sum=0;
reverse(x.begin(),x.end());
reverse(y.begin(),y.end());
for(int i=0;x.size()>i||y.size()>i;i++)
{
if(x.size()>i)sum+=x[i]-'0';
if(y.size()>i)sum+=y[i]-'0';
z.push_back(sum%10+'0');
sum/=10;
}
if(sum!=0)z.push_back('1');
reverse(z.begin(),z.end());
return z;
}
string operator -(string x,string y)
{
string z;
int sum=0;int fl=0;
reverse(x.begin(),x.end());
reverse(y.begin(),y.end());
if(x.size()<y.size() || (x.size()==y.size() && x<y)){swap(x,y);fl=1;}
for(int i=0;x.size()>i;i++)
{
sum=0;
sum+=x[i]-'0';
if(y.size()>i)sum-=y[i]-'0';
if(sum<0)
{
sum+=10;
x[i+1]--;
}
z.push_back(sum+'0');
}
while(z.size()>1 && z.back()=='0')z.pop_back();
if(fl==1)z.push_back('-');
reverse(z.begin(),z.end());
return z;
}
string operator *(string x,string y)
{
string z;
reverse(x.begin(),x.end());
reverse(y.begin(),y.end());
for(int i=0;i<x.length();i++)
{
for(int j=0;j<y.length();j++)
{
if(i+j>=z.length())z.push_back('0');
int sum=(x[i]-'0')*(y[j]-'0')+(z[i+j]-'0');
z[i+j]=sum%10+'0';
if(i+j+1>=z.length())z.push_back('0');
z[i+j+1]+=sum/10;
}
}
while(z.size()>1 && z.back()=='0')z.pop_back();
reverse(z.begin(),z.end());
return z;
}
string operator /(string x,string y)
{
string z,k;
for(int i=0;i<x.size();i++)
{
k.push_back(x[i]);
int cnt=0;
while(k.size()>y.size()||(k.size()==y.size() && k>=y))
{
k=k-y;
cnt++;
}
z.push_back(cnt+'0');
}
reverse(z.begin(),z.end());
while(z.size()>1 && z.back()=='0')z.pop_back();
reverse(z.begin(),z.end());
return z;
}
string operator %(string x,string y)
{
string z,k;
for(int i=0;i<x.size();i++)
{
k.push_back(x[i]);
int cnt=0;
while(k.size()>y.size()||(k.size()==y.size() && k>=y))
{
k=k-y;
cnt++;
}
z.push_back(cnt+'0');
}
return k;
}