#45819: 小蜜蜂剛剛發現漏打了這一題的解題報告


1121226@stu.wghs.tp.edu.tw (Arthur✨EC✨小蜜楓)

學校 : 臺北市私立薇閣高級中學
編號 : 252772
來源 : [60.248.154.139]
最後登入時間 :
2025-05-14 12:52:05
a623. 3. Combination -- HP CodeWars2007 | From: [60.248.154.139] | 發表日期 : 2025-04-17 13:02

#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b;
    while(cin>>a>>b){ // 輸入
        long long int c = 1, d = 1, e = 1;
        for(int i=1;i<=a;i++){ // a!
            c*=i;
        }
        for(int i=1;i<=b;i++){ // b!
            d*=i;
        }
        for(int i=1;i<=a-b;i++){ // (a-b)!
            e*=i;
        }

        cout<<c/(d*e)<<endl;
    }
    return 0;
}
 
ZeroJudge Forum