记录编号 105917 评测结果 AAAAAAAAAAAAAAAAAAAA
题目名称 出栈序列统计 最终得分 100
用户昵称 GravatarOIdiot 是否通过 通过
代码语言 C++ 运行时间 0.188 s
提交时间 2014-06-12 19:31:22 内存使用 0.70 MiB
显示代码纯文本
#include <cstdio>
#include <iostream>
#include <ctime>
#include <algorithm>
#include <cstring>
#define SpeedUp ios::sync_with_stdio(false)
#define BigN_MAXN 50000
#define INF (1<<28)
#define FILE
//#define Debug
using namespace std;
typedef long long LL;

int N,Sum;

struct BigN{
	int Len,s[BigN_MAXN];
	
	BigN(){
		memset(s,0,sizeof(s));
		Len=1;
	}
	
	BigN(int num){
	*this=num;
	}
	
	BigN(const char*num){
	*this=num;
	}
	
	BigN operator = (int num){
		char s[BigN_MAXN];
		sprintf(s,"%d",num);
		*this=s;
		return *this;
	}
	
	BigN operator = (const char *num){
		Len=strlen(num);
		for(int i=0;i<Len;i++)
			s[i]=num[Len-i-1]-'0';
		return *this;
	}
	
	string str()const{
		string res="";
		for(int i=0;i<Len;i++)
			res=(char)(s[i]+'0')+res;
		if(res=="")
			res="0";
		return res;
	}
	
	BigN operator + (const BigN &b)const{
		BigN c;
		c.Len=0;
		for(int i=0,g=0;g||i<max(Len,b.Len);i++){
			int x=g;
			if(i<Len)
				x+=s[i];
			if(i<b.Len)
				x+=b.s[i];
			c.s[c.Len++]=x%10;
			g=x/10;
		}
		return c;
	}
	
	void clean(){
		while(Len>1&&!s[Len-1])
			Len--;
	}
	
	BigN operator * (const BigN &b){
		BigN c;
		c.Len=Len+b.Len;
		for(int i=0;i<Len;i++)
			for(int j=0;j<b.Len;j++)
				c.s[i+j]+=s[i]*b.s[j];
		for(int i=0;i<c.Len-1;i++){
			c.s[i+1]+=c.s[i]/10;
			c.s[i]%=10;
		}
		c.clean();
		return c;
	}
	
	BigN operator - (const BigN &b){
		BigN c;
		c.Len=0;
		for(int i=0,g=0;i<Len;i++){
			int x=s[i]-g;
			if(i<b.Len)x-=b.s[i];
			if(x>=0)
				g=0;
			else{
				g=1;
				x+=10;
			}
			c.s[c.Len++]=x;
		}
		c.clean();
		return c;
	}
	
	BigN operator / (LL b){
		BigN c;
		c.Len=Len;
		int r=0;
		for(int i=Len-1;i>=0;i--){
			c.s[i]=(r*10+s[i])/b;
			r=(r*10+s[i])%b;
		}
		c.clean();
		return c;
	}
	
	bool operator < (const BigN &b)const{
		if(Len!=b.Len)
			return Len<b.Len;
		for(int i=Len-1;i>=0;i--)
			if(s[i]!=b.s[i])
				return s[i]<b.s[i];
		return false;
	}
	
	bool operator > (const BigN &b)const{
		return b<*this;
	}
	
	bool operator <= (const BigN &b){
		return !(b>*this);
	}
	
	bool operator == (const BigN &b){
		return !(b<*this)&&!(*this<b);
	}
	
	BigN operator += (const BigN &b){
		*this=*this+b;
		return *this;
	}
};

istream &operator >> (istream &in,BigN &x){
	string s;
	in>>s;
	x=s.c_str();
	return in;
}

ostream &operator << (ostream &out,const BigN &x){
	out<<x.str();
	return out;
}

void init()
{
	#ifdef FILE
	SpeedUp;
	freopen("stack1.in","r",stdin);
	freopen("stack1.out","w",stdout);
	#endif
	cin>>N;
}

BigN h=1,tmp;

void Calc(){
	for(int i=2;i<=N;i++){
		BigN t=4*i-2;
		tmp=t*h;
		h=tmp/(i+1);
	}
	cout<<h<<endl;
}

int main(){
	init();
	Calc();
	#ifdef Debug
	cout<<"Time Used : "<<(double)clock()/CLOCKS_PER_SEC<<endl;
	#endif
	return 0;
}