Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:为什么错了

Posted by xinghe at 2006-05-01 12:03:31 on Problem 1633
In Reply To:为什么错了 Posted by:xinghe at 2006-05-01 09:24:10
> 帮忙看一下
> #include<iostream.h>
> #include<stdlib.h>
> #define M 20
> int Bit(unsigned long int p)
> {
> 	int bit=0;
> 	while(p!=0)
> 	{
> 		p=p/10;
> 		bit++;
> 	}
> 	return bit;
> }
> class Longint
> {
> public:
> 	Longint()
> 	{
> 		for(int i=0;i<M;i++) num[i]=0;
> 	}
> 	Longint operator =(Longint other)
> 	{
> 		for(int i=0;i<M;i++) num[i]=other.num[i];
> 		return *this;
> 	}
> 	Longint(int i)
> 	{
>         for(int j=0;j<M-1;j++) num[j]=0;
> 		num[M-1]=i;
> 	}
> 	friend Longint operator +(Longint p,Longint other)
> 	{
> 		Longint p1;
> 		int bit=0;
> 		for(int i=M-1;i>=0;i--)
> 		{
> 			p1.num[i]=p.num[i]+other.num[i]+bit;
> 			if(p1.num[i]>=1000000000)
> 			{
> 				p1.num[i]=p1.num[i]-1000000000;
> 				bit=1;
> 			}
> 			else bit=0;
> 		}
> 		return p1;
> 	}
> 	friend ostream& operator <<(ostream& out,Longint& p)
> 	{
> 		int i=0;
> 		while(p.num[i]==0&&i<M) i++;
> 		if(i==M) out<<0;
> 		else
> 		{
> 			out<<p.num[i];
> 		    for(int j=i+1;j<M;j++)
> 			{
> 			for(int bit=1;bit<=9-Bit(p.num[j]);bit++) out<<0;
> 			out<<p.num[j];
> 			}
> 		}
> 		return out;
> 	}
> private:
> 	unsigned long int num[M];
> };
> Longint tab[52][52];
> int main()
> {
> 	Longint a[50];
> 	int i,k,j,t;
> 	Longint s;
> 	for(i=0;i<52;i++)
> 	{
> 		tab[i][1]=Longint(1);
> 		tab[i][0]=Longint(0);
> 	}
> 	for(i=0;i<52;i++)
> 	{
> 		for(k=i+1;k<52;k++) tab[i][k]=Longint(0);
> 	}
> 	for(i=2;i<52;i++)
> 	{
> 		for(k=2;k<=i;k++)
> 		{
> 			s=Longint(0);
> 			for(j=1;j<=k;j++) s=s+tab[i-1][k];
> 			for(j=1;j<=2*i-k;j++) s=s+tab[i-1][k-1];
> 			tab[i][k]=s;
> 		}
> 	}
> 	cin>>t;
> 	j=0;
> 	while(t>=1)
> 	{
> 		cin>>i>>k;
> 		if(i==0&&k==0) cout<<1<<endl;
> 		if(k==1) cout<<1<<endl;
> 		 else if(k>i||k<1) cout<<0<<endl;
> 		 else cout<<tab[i][k]<<endl;
> 		 t--;
> 	}
> 
> 	return 0;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator