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

我的郁闷经历……

Posted by zst at 2007-04-20 12:38:04 on Problem 1306
#include <iostream.h>

unsigned int matrix[101][101];

unsigned int Method(int N, int M)
{
	if(N==M) return 1;
	if(M==0) return 1;//if(M==1) return N
	if(matrix[N][M]>0)
	{
		return matrix[N][M];
	}
	matrix[N][M]=Method(N-1, M) + Method(N-1, M-1);
	return matrix[N][M];
}

void main()
{
	int N, M;
	while(cin>>N>>M)
	{
		if(N==0) break;

		cout<<N<<" things taken "<<M<<" at a time is ";	
		if(M>N-M) M=N-M;
		cout<<Method(N, M)<<" exactly."<<endl;
	}
}

就是本注释了的那一句让我郁闷了很久的。
唉,有些错误还真是不容易发现

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