zoukankan      html  css  js  c++  java
  • CodeForces 131C C (组合)

    There are n boys and m girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing exactly t actors containing no less than 4 boys and no less than one girl. How many ways are there to choose a group? Of course, the variants that only differ in the composition of the troupe are considered different.

    Perform all calculations in the 64-bit type: long long for С/С++, int64 for Delphi and long for Java.

    Input

    The only line of the input data contains three integers n, m, t (4 ≤ n ≤ 30, 1 ≤ m ≤ 30, 5 ≤ t ≤ n + m).

    Output

    Find the required number of ways.

    Please do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specificator.

    Sample Input

    Input
    5 2 5
    Output
    10
    Input
    4 3 5
    Output
    3
    n个人,男生大于四个,女生大于一个,高中的排列组合
     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cmath>
     4 typedef long long ll;
     5 using namespace std;
     6 ll fun(ll a, ll b)
     7 {
     8     ll temp=1;
     9     for(int j=1;j<=b; j++)
    10     {
    11         temp=temp*a/j;
    12         a--;
    13     }
    14     return temp;
    15 }
    16 int main()
    17 {
    18     ll m,n,t;
    19     int i,j;
    20     cin>>m>>n>>t;
    21     ll sum=0;
    22     for(i=4;i<t&&i<=m;i++)
    23     {
    24         if(t-i>=1&&t-i<=t-4&&t-i<=n)
    25             sum=sum+fun(m,i)*fun(n,t-i);
    26     }
    27     cout<<sum<<endl;
    28     return 0;
    29 }
  • 相关阅读:
    FTP概述
    day1 基础总结
    数据库简介
    数据库基础——写在前面的话
    常用markdown语法入门
    【搬运工】——Java中的static关键字解析(转)
    【搬运工】——初识Lua(转)
    【搬运工】之YSlow安装教程
    Chome——扩展程序,获取更多扩展程序报错
    node.js 下载安装及gitbook环境安装、搭建
  • 原文地址:https://www.cnblogs.com/Aa1039510121/p/5693357.html
Copyright © 2011-2022 走看看