UVa 10105 - Polynomial Coefficients

题目:给你一个多项式(x1+x2+..+xk)^ n,求x1^k1*x2^k2*..*xn^kn的系数。

分析:组合数学,多项式系数。

系数为:C(n,k1)* C(n-k1,k2)* .. *C(n-k1-..-kn-1,kn)= n! /(k1!k2!..kn!)。

说明:好久没怎么刷题了╮(╯▽╰)╭。

#include <iostream>

using namespace std;

int f[13],p[13];

int main()
{
	f[0] = 1;
	for (int i = 1; i < 13; ++ i)
		f[i] = f[i-1]*i;
	int n,k;
	while (cin >> n >> k) {
		for (int i = 0; i < k; ++ i)
			cin >> p[i];
		int value = f[n];
		for (int i = 0; i < k; ++ i)
			value /= f[p[i]];
		cout << value << endl;
	}
    return 0;
}
时间: 2024-08-30 08:03:04

UVa 10105 - Polynomial Coefficients的相关文章

UVA 10951 - Polynomial GCD(数论)

UVA 10951 - Polynomial GCD 题目链接 题意:给定两个多项式,求多项式的gcd,要求首项次数为1,多项式中的运算都%n,并且n为素数. 思路:和gcd基本一样,只不过传入的是两个多项式,由于有%n这个条件,所以计算过程可以用乘法逆去计算除法模,然后最后输出的时候每项除掉首项的次数就是答案了. 代码: #include <stdio.h> #include <string.h> #include <vector> using namespace s

uva 10951 - Polynomial GCD(欧几里得)

题目链接:uva 10951 - Polynomial GCD 题目大意:给出n和两个多项式,求两个多项式在所有操作均模n的情况下最大公约数是多少. 解题思路:欧几里得算法,就是为多项式这个数据类型重载取模运算符,需要注意的是在多项式除多项的过程中,为了保证各项系数为整数,需要将整个多项式的系数整体扩大至一定倍数,碰到先除后模的时候要用逆元. #include <cstdio> #include <cstring> const int maxn = 105; int M; void

UVA 10951 Polynomial GCD 多项式欧几里德求最大公共多项式

今天作比赛遇上了HDU3892,都分析出来怎么做了,可惜不会求多项式的最大公共多项式,当时写了半天,案例也没有跑出来,赛后搜了一下题解,发现有大神做出了,而且是有模版的,不过又搜了一下关于这方面的题目,很少,只发现了这一道,所以先做一下这一道吧 题意,给你两个多项式,求他们的最大公共多项式,然后输出即可,无齿的套用了别人的模版,呵呵! #include<iostream> #include<cstdio> #include<list> #include<algor

【数论】UVa 10586 - Polynomial Remains

Problem F: Polynomial Remains Given the polynomial a(x) = an xn + ... + a1 x + a0, compute the remainder r(x) when a(x) is divided by xk+1. The input consists of a number of cases. The first line of each case specifies the two integers n and k (0 ≤ n

UVA - 10951 Polynomial GCD (最大公共多项式)

Description Problem C Polynomial GCD Input: standard input Output: standard output Given two polynomials f(x) and g(x) in Zn, you have to find their GCD polynomial, ie, a polynomial r(x) (also in Zn) which has the greatest degree of all the polynomia

UVA10105 - Polynomial Coefficients(排列组合)

题目链接 题目大意:给你k个数,然后求(x1 + x2 + x3 +.. + xk)^n的x1^n1x2^n2x3^n3...xk^nk这个数的系数.题目会给n和k,然后给出k个ni,并且保证n1+ n2 + ..+nk = n. 解题思路:根据二项式的系数的求法,类似的也用组合来求这个数的系数.对于这个x1^n1..xk^nk这个数的系数,就等于每个单独的xi^ni的系数的积.容易得出这个数的系数是 n!/(n1!?(n - n1)!) ? (n - n1)! / (n2! ? (n - n1

UVA题目分类

题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics 10300 - Ecological Premium 458 - The Decoder 494 - Kindergarten Counting Game 414 - Machined Surfaces 490 - Rotating Sentences 445 - Marvelous Mazes

计划,,留

下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinejudge.org 西班牙Valladolid大学的程序在线评测系统,是历史最悠久.最著名的OJ. 一.<算法竞赛入门经典> 刘汝佳 (UVaOJ 351道题) 以下部分内容摘自:http://sdkdacm.5d6d.com/thread-6-1-1.html "AOAPC I"

算法竞赛入门经典+挑战编程+USACO

下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发.   一.UVaOJ http://uva.onlinejudge.org  西班牙Valladolid大学的程序在线评测系统,是历史最悠久.最著名的OJ.   二.<算法竞赛入门经典> 刘汝佳  (UVaOJ  351道题)  以下部分内容摘自:http://sdkdacm.5d6d.com/thread-6-1-1.html   "AO