}
return os;
}
istream& operator>>(istream& is, bigNumber &big)//输入高精度运算符的重载
{
string s;
is>>s;
intlength=s.size();
for(int i=0;i
{
char a=s[i];
s[i]=s[length-1-i];
s[length-1-i]=a;
}
int m=1;
for(int i=0;i
{
int a=s[i]-'0';
big.num[i/4]+=a*m;
m*=10;
if(m==10000)
m=1;
}
big.ans=(length-1)/4+1;
return is;
}
bigNumber operator*(bigNumber big1,bigNumberbig2)//两个高精度数相乘
{
bigNumber big3;
for(int i=0;i
{
for(int j=0;j
{
inta=big1.num[i]*big2.num[j];
big3.num[i+j]+=a000;
big3.num[i+j+1]+=a/10000;
}
for(int k=i;k<=i+big2.ans;k++)
{
if(big3.num[k]>=10000)
{
big3.num[k+1]+=big3.num[k]/10000;
big3.num[k]=big3.num[k]000;
}
}
}
big3.ans=big1.ans+big2.ans;
while(big3.num[big3.ans]==0)
big3.ans--;
big3.ans++;
if(big3.ans==0)
big3.ans++;
returnbig3;
}
bigNumber operator*(bigNumber big,intk)//高精度乘以普通常数(注意常数的大小范围不可太大)
{
bigNumber tool;
for(int i=0;i
{
int product=big.num[i]*k;
tool.num[i]+=product000;
int j=i;
while(product>=10000)
{
product/=10000;
tool.num[++j]+=product000;
}
}
tool.ans=big.ans+10;
while(tool.num[tool.ans]==0)
tool.ans--;
tool.ans++;
big=tool;
return big;
}
bigNumber operator+(bigNumber big1,bigNumberbig2)//两个高精度数相加,将和赋在第一个数上
{
bigNumber tool=big1;
for(int i=0;i
{
tool.num[i]+=big2.num[i];
int j=i;
while(tool.num[j]>=10000)
{
inta=tool.num[j];
tool.num[j]=a000;
tool.num[j+1]+=a/10000;
j++;
}
}
tool.ans=max(big1.ans+1,big2.ans+1);
while(tool.num[tool.ans]==0)
tool.ans--;
tool.ans++;
return tool;
}
bigNumber operator/(bigNumber &big1,int k)
{
int i=big1.ans-1;
int a;
while(i>=0)
{
a=big1.num[i];
big1.num[i]=0;
while(i>0&&a
{
a*=10000;
a+=big1.num[--i];
big1.num[i]=0;
}
big1.num[i]=a/k;
if(i==0)
break;
if(i>0)
big1.num[--i]+=(a%k)*10000;
}
while(big1.num[big1.ans]==0)
big1.ans--;
big1.ans++;
return big1;
}
bigNumber function0(int n)
{
if(n==1||n==2)
{
bigNumber big;
big.num[0]=1;
return big;
}
if(remember[n])
return number[n];
bigNumber tool;
for(int k=1;k
{
bigNumber big1=function0(k);
bigNumber big2=function0(n-k);
bigNumber big3;
big3.num[0]=1;
for(int i=n-2;i>n-2-k+1;i--)
{
big3=big3*i;
}
for(int i=2;i<=k-1;i++)
big3=big3/i;
bigNumber big4;
big4.num[0]=1;
for(int i=1;i<=k;i++)
big4=big4*2;
big4.num[0]-=1;
tool=tool+(big1*big2*big3*big4);
}
remember[n]=true;
number[n]=tool;
return tool;
}
int main()
{
for(inti=0;i<=50;i++)
remember[i]=false;
int n;
while(scanf("%d",&n)!=EOF&&n!=0)