The coefficient of x1n1x2n2... xknk is (n, N1) (n-n1, N2)... (n-n1-n2-...-NK-1, NK) = n! /N1! N2 !... NK !.
Code:
- /*************************************** **********************************
- * Copyright (c) 2008 by liukaipeng *
- * Liukaipeng at gmail dot com *
- **************************************** *********************************/
- /* @ Judge_id 00000 10105 C ++ "polynomial coefficients "*/
- # Include <algorithm>
- # Include <cstdio>
- # Include <cstring>
- # Include <deque>
- # Include <fstream>
- # Include <iostream>
- # Include <list>
- # Include <map>
- # Include <queue>
- # Include <set>
- # Include <stack>
- # Include <string>
- # Include <vector>
- Using namespace STD;
- Int main (INT argc, char * argv [])
- {
- # Ifndef online_judge
- Freopen (string (argv [0]) + ". In"). c_str (), "r", stdin );
- Freopen (string (argv [0]) + ". Out"). c_str (), "W", stdout );
- # Endif
- Int factorials [] = {1, 1, 2, 6, 24,120,720,504 0, 40320,362 880,
- 3628800,399 16800, 479001600 };
- For (int n, K; CIN> N> K ;){
- Int c = factorials [N];
- For (INT I = 0, T; I <K & CIN> T; ++ I)
- C/= factorials [T];
- Cout <C <'/N ';
- }
- Return 0;
- }