為了呼應台灣電腦彩券的發行,我們特別推出跟組合有關的題目。以台灣的彩券來說,從 46 個球中取出 6 個,共有 C(46,6)=9366819 種組合。(中特獎的機率:1/936681989,夠低了吧!) 給你:
5≤N≤100,5≤M≤100,M≤N我們可以根據下面的公式算出從 N 個東西中取出 M 個東西的組合數:
C=N!(N−M)!M!你可以假設你的答案 C 不會超出 long int 的範圍。
Input
每筆測試資料一行,有 2 個正整數 N,M。N=0,M=0 代表輸入結束。
Output
以下列的格式輸出:
N things taken M at a time is C exactly.
請參考 Sample Output。
Sample Input
100 6
20 5
18 6
0 0
Sample Output
100 things taken 6 at a time is 1192052400 exactly.
20 things taken 5 at a time is 15504 exactly.
18 things taken 6 at a time is 18564 exactly.