日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

The World is a Theatre(组合数学)

發布時間:2023/12/15 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 The World is a Theatre(组合数学) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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.

Examples
Input
5 2 5
Output
10
Input
4 3 5
Output
3
挺水的這道題,但是一次做對也不是很容易。首先打表求出組合數。其次數組不要開得太小,dp[i][j],如果j>i的時候,就是0。
代碼如下:

#include<bits/stdc++.h> #define ll long long using namespace std;const int maxx=100; int n,m,t; ll dp[maxx][maxx];inline void init() {memset(dp,0,sizeof(dp));for(int i=0;i<=30;i++){dp[0][i]=0;dp[i][0]=1ll;}for(int i=1;i<=30;i++){for(int j=1;j<=i;j++){dp[i][j]=(dp[i-1][j]+dp[i-1][j-1]);}} } int main() {init();while(~scanf("%d%d%d",&n,&m,&t)){if(t<5||n<4||m<1) puts("0");else{ll sum=0;for(int i=4;i<=n&&t-i>=1;i++){sum+=dp[n][i]*dp[m][t-i];//單純的排列組合}printf("%I64d\n",sum);}} }

努力加油a啊,(o)/~

總結

以上是生活随笔為你收集整理的The World is a Theatre(组合数学)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。