| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
我的郁闷经历……#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator