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 guochuangchuang at 2014-05-30 18:28:50 on Problem 1953
In Reply To:高中的排列组合,插空法。。。还记得否???没想到在这里能用上。。。 Posted by:806601756 at 2011-07-26 10:57:53
> #include <stdio.h>
> #include <memory.h>
> 
> __int64 v[50][50];
> 
> __int64 c(int m,int n)
> {
> 	if(n==0||m==n)return 1;
> 	else if(n==1)return m;
> 	else 
> 	{
> 		if(v[m][n]==-1)
> 			v[m][n]=c(m-1,n)+c(m-1,n-1);
> 		return v[m][n];
> 	}
> }
> 
> int main()
> {
> 	int cases ,n,a,b,i,w=0;
> 	__int64 sum=0;
> 	scanf("%d",&cases);
> 	while (cases--)
> 	{
> 		w++;
> 		memset(v,-1,sizeof(v));
> 		sum=0;
> 		scanf("%d",&n);
> 		a=(int)((n+1)/2);
> 		for(i=0;i<=a;i++)
> 		{
> 			b=n-i+1;
> 			sum=sum+c(b,i);
> 		}
> 		printf("Scenario #%d:\n",w);
> 		printf("%I64d\n",sum);
> 		if(cases>0)printf("\n");
> 	}
> 	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