`
249326109
  • 浏览: 56242 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

pat 1009. Product of Polynomials (25)

 
阅读更多

链接:http://pat.zju.edu.cn/contests/pat-a-practise/1009

 

题意:计算多项式的乘积。

 

分析:基于编程方便,还是采用数组的方式来实现。

 

#include<stdio.h>

typedef struct Poly {
	int exp;
	double coe;
} Poly;

Poly a[1005];
Poly b[1005];
double res[2005];

int main() {
	int n;
	scanf("%d", &n);
	int i;
	for (i = 0; i < n; i++) {
		scanf("%d%lf", &a[i].exp, &a[i].coe);
	}
	int m;
	scanf("%d", &m);
	for (i = 0; i < m; i++) {
		scanf("%d%lf", &b[i].exp, &b[i].coe);
	}
	int j;
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++) {
			res[a[i].exp + b[j].exp] += a[i].coe * b[j].coe;
		}

	int count = 0;
	for (i = 0; i < 2005; i++) {
		if (res[i]) {
			count++;
		}

	}

	printf("%d", count);

	for (i = 2005; i >= 0; i--) {
		if (res[i])
			printf(" %d %.1lf", i, res[i]);
	}

	printf("\n");

	return 0;
}

 

 

 

分享到:
评论

相关推荐

    pat题目分类.docx

    - **多项式乘法** (1009 Product of Polynomials): 哈希表用于存储系数,解决大整数乘法问题。 - **指数与系数映射** (1002 A+B for Polynomials): 应用哈希表存储多项式的指数和系数。 3. **图论问题**: - **...

    Channel Coding in Communication Networks

    25 1.5.6. Fundamental theorem: Gallager’s proof . . . . . . . . . . . . . . . . 26 1.5.6.1. Upper bound of the probability of error. . . . . . . . . . . . . . . 27 1.5.6.2. Use of random coding . . ...

    Error Correction coding——mathematical methods and algorithms

    1.1 F’urpose of This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2 Introduction: Where Are Codes? . . . . . . . . . . . . . . . . . . . . . . . 2 1.3 The Communications System ...

    Computing Roots of Polynomials

    ### 计算多项式的根 #### 概述 在计算机辅助几何设计(CAGD)领域,计算多项式的根是一项核心任务。对于多项式方程的解法,传统的代数方法往往只适用于低次多项式,而对于高次多项式,则需要借助数值方法来求解。...

    PAT甲级真题练习1

    9. Product of Polynomials (25) Product of Polynomials是一个中等难度的多项式计算题,要求考生编写一个程序来计算多项式的乘积。该题目考察了考生的多项式计算能力和算法设计能力。 知识点: * 多项式计算 * ...

    XNUMBERS 5.6 - Multi Precision Floating Point Computing and Numerical Methods for EXCEL

    Derivatives of polynomials. Interpolation with Newton formula. Rootfinder algorithms: Jenkins-Traub, Durand-Kerner-Aberth, Newton Generalized, Laguerre, Siljak, Ruffini. Orthogonal polynomials. ...

    PAT甲级题解.pdf

    2. 多项式求和:在题解1002 "A+B for Polynomials"中,提到了处理两个多项式的求和问题。输入包含两行,每行表示一个多项式,多项式由指数和对应的系数构成,指数从大到小排列,且无重复。求和后输出的多项式也遵循...

    zernike polynomials.docx

    Zernike多项式在数学中是一组在单位圆盘上正交的多项式,由诺贝尔奖得主、光学物理学家Frits Zernike命名,他也是相位对比显微镜的发明者。Zernike多项式在光束光学领域扮演着重要的角色,尤其在反射面天线的优化中...

    Principles of Spread-Spectrum Communication Systems 3rd

    Characteristic Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Long Nonlinear Sequences. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 ChipWaveforms...

    Orthogonal Polynomials and Continued Fractions

    and how Brouncker's formula of 1655 can be derived from Euler's efforts in Special Functions and Orthogonal Polynomials. The most interesting applications of this work are discussed, including the ...

    Comprehensive Mathematics for Computer Scientists 2nd ed [Vol 1]

    16.2Roots of Polynomials and Interpolation .................. 186 17 Formal Propositional Logic 191 17.1Syntactics: The Language of Formal Propositional Logic .. 193 17.2Semantics: Logical Algebras......

    13623-calculate-roots-of-chebyshev-polynomials.zip.zip

    在给定的压缩包文件"13623-calculate-roots-of-chebyshev-polynomials.zip.zip"中,我们可以推测其内容可能与计算切比雪夫多项式的根有关。切比雪夫多项式是一类在数值分析和工程计算中非常重要的特殊函数,它们在...

    Hermite-Matlab.rar_Hermite polynomials_hermite_hermite 插值_hermit

    Hermite插值多项式拟合Matlab程序。运用Matlab软件依据理论可画出Hermite插值图像,并求出Hermite多项式,并应用到实际问题中。

    The-sum-of-polynomials.zip_SUM_行列式

    标题“‘The-sum-of-polynomials.zip_SUM_行列式’”暗示了我们将探讨如何利用行列式来处理多项式的加法问题,而标签“sum”和“行列式”进一步强化了这一主题。 首先,让我们定义一下多项式。一个多项式是由常数、...

    Continued fractions and the derangement polynomials of types $A$ and $B$

    连分式是一种表达形式,由一系列数字构成,其中每个数字由两个分数形式的项之间加号隔开,这种形式的数学表达式可以用来表达复杂的数学运算,包括无理数的近似值,例如π、e等的表示。连分式在许多数学分支中都有...

    'Fast construction of irreducible polynomials over finite fields'.pdf

    文档《Fast construction of irreducible polynomials over finite fields》由Jean-Marc Couveignes和Reynald Lercier撰写,提供了在有限域上构建不可约多项式的快速随机化算法。文章提出了一个基于随机方法的算法,...

    Handbook of Mathematical Functions With Formulas, Graphs, and Mathematical Table

    Despite the increasing use of computers, the basic need for mathematical tables continues. Tables serve a vital role in preliminary surveys of problems before programming for machine operation, and ...

Global site tag (gtag.js) - Google Analytics