TopCoder

User's AC Ratio

100.0% (1/1)

Submission's AC Ratio

50.0% (1/2)

Tags

Description

小 U 最近在複習排列組合,想請你幫他驗算排列組合的答案。他需要你幫忙寫出計算階乘和排列組合數的函式。

階乘參考計算方法:
$m! = \begin{cases}
1,\quad \texttt{if}\ m=0 \
1 \times 2 \times\dots\times m,\quad \texttt{if}\ m>0
\end{cases}$

排列組合參考計算方法:
$C(n,k) = \frac{n!}{k!(n-k)!}$

註:此題為互動題,請以下面的格式提交 code,你只需要完成函式的部分(提交時要交包含以下部分的 code)。

#include "lib0602.h"
int factorial(int m)
{
    // your code
}

int comb(int n,int k){
    // your code
}

Input Format

函式的三個參數請參考題敘。

  • $0 \leq \textrm{n, m} \leq 12$
  • $0 \leq k \leq n$

請不要輸入任何東西。

Output Format

讓回傳函式計算結果。
請不要輸出任何東西。

Hints

測試用標頭檔
這裡提供一份本地測試用的標頭檔,你可以將其複製下來存檔成 lib0602.h#include "lib0602.h" 做使用。但請注意,這只是測試用的標頭檔,一些與解題無關的行為將會與 judge 上的有所不同,因此請不要嘗試任何與解題無關的行為,很可能會導致各種不可預期的後果。

Problem Source

Subtasks

No. Testdata Range Constraints Score
1 0 範例測資 0
2 0~6 無額外限制 100

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 524288 65536 1 2
1 1000 524288 65536 2
2 1000 524288 65536 2
3 1000 524288 65536 2
4 1000 524288 65536 2
5 1000 524288 65536 2
6 1000 524288 65536 2