zoukankan      html  css  js  c++  java
  • Codeforces 131C . The World is a Theatre(打表组合数)

    题目链接:http://codeforces.com/contest/131/problem/C

    大意就是有n个男孩,m个女孩,从男孩中选不少于4个男孩,女孩中选不少于1个女孩,组成人数为t的队伍,问有几种可能的组合,高中的排列组合题目,组合数和杨辉三角形表是一一对应的,打一个表,依次对应着加和就可以了。

    AC代码:

    #include<iostream>
    #include<vector>
    #include<algorithm>
    using namespace std;
    #define ll long long 
    ll C[35][35];//杨辉三角形表 
    void getC(){
    	for(ll int i = 0;i<=35;i++){
    		for(ll int j = 0;j<=35;j++){
    			if(j == 0 || i == 0){
    				C[i][j] = 1;
    			}
    			else{
    				C[i][j] = C[i][j-1] + C[i-1][j];
    			}
    		}
    	}
    }
    int main(){
    	int n,m,t;
    	cin>>n>>m>>t;
    	getC();
    	ll int ans = 0;
    	for(int i = 4;i<=n;i++){
    		for(int j = 1;j<=m;j++){
    		    if(i+j ==t){
    				int boy1 = 1+n-i;
    				int boy2 = 1+i;
    				int girl1 = 1+m-j;
    				int girl2 = 1+j;
    				ans+=C[boy1-1][boy2-1]*C[girl1-1][girl2-1];
    			}
    		}
    	}
    	cout<<ans;
    	return 0;
    	
    }
  • 相关阅读:
    飞机大战4-我的子弹
    飞机大战3-我的飞机
    飞机大战1-分析设计
    继承
    常见题
    42个例子算法
    心跳
    tomcat
    service
    URI URL
  • 原文地址:https://www.cnblogs.com/AaronChang/p/12129647.html
Copyright © 2011-2022 走看看