两个多项式的乘积

两个数组,一个放多项式1,一个放结果

注意:arr2[j+exp]+=arr1[j]*coe; 因为有指数相加相同的情况下需要合并系数

 #include<cstdio>
int main(){
double arr1[]={0.0},arr2[]={0.0},coe;
int exp,count=,n,m;
scanf("%d", &n);
for(int i=;i<n;i++){
scanf("%d%lf",&exp,&coe);
arr1[exp]=coe;
}
scanf("%d", &m);
for(int i=;i<m;i++){
scanf("%d%lf", &exp,&coe);
for(int j=;j<=;j++)
arr2[j+exp]+=arr1[j]*coe;//加出来指数相同的系数要相加
}
for(int i=;i<=;i++){
if(arr2[i]!=0.0)
count++;
}
printf("%d",count);
for(int i=;i>=;i--){
if(arr2[i]!=0.0) printf(" %d %.1lf",i,arr2[i]);
}
return ;
}

A1009的更多相关文章

  1. A1009 Product of Polynomials (25)(25 分)

    A1009 Product of Polynomials (25)(25 分) This time, you are supposed to find A*B where A and B are tw ...

  2. PTA A1009&A1010

    第五天 A1009 Product of Polynomials (25 分) 题目内容 This time, you are supposed to find A×B where A and B a ...

  3. A1009. Product of Polynomials

    This time, you are supposed to find A*B where A and B are two polynomials. Input Specification: Each ...

  4. PAT A1009 Product of Polynomials (25 分)——浮点,结构体数组

    This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: Each ...

  5. PAT A1009 Product of Polynomials(25)

    课本AC代码 #include <cstdio> struct Poly { int exp;//指数 double cof; } poly[1001];//第一个多项式 double a ...

  6. PAT甲级——A1009 Product of Polynomials

    This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: Each ...

  7. PAT/简单模拟习题集(二)

    B1018. 锤子剪刀布 (20) Discription: 大家应该都会玩"锤子剪刀布"的游戏:两人同时给出手势,胜负规则如图所示: 现给出两人的交锋记录,请统计双方的胜.平.负 ...

  8. iot表和heap表排序规则不同

    SQL> select * from (select * from t1 order by id ) where rownum<20; ID A1 A2 A3 ---------- --- ...

  9. Oracle 排序规则

    <pre name="code" class="html">SQL> select * from t1 where id>=1 and ...

随机推荐

  1. Java 项目管理工具 - Maven

    类似于 PHP 中的 Composer,NodeJS 中的 npm,Java 用 Maven 来管理依赖关系. 实际上,Maven 负责管理 Java 项目开发过程中的几乎所有的东西: 版本控制:Ma ...

  2. c++ 调用 sqlite

    #include <iostream> #include "sqlite3.h" using namespace std; void dbTest() { #pragm ...

  3. centos7:Zookeeper集群安装

    将安装包上传到安装目录 解压文件 tar -zxvf zookeeper-3.4.12.tar.gz 移动解压后的文件到软件目录 mv zookeeper-3.4.12 /home/softwareD ...

  4. python并发编程之进程池、线程池、协程

    需要注意一下不能无限的开进程,不能无限的开线程最常用的就是开进程池,开线程池.其中回调函数非常重要回调函数其实可以作为一种编程思想,谁好了谁就去掉 只要你用并发,就会有锁的问题,但是你不能一直去自己加 ...

  5. 关于golang的label

    1 label所在的代码段在没有跳转的时候按照所在的位置按顺序执行 2 break label和continue label可以一次性从多重循环中跳出 3 goto label的用法和c/c++中的一 ...

  6. 安装Linux系统CentOS6.5

    个人机器搭建分布式环境时避免要使用虚拟机来满足分布式环境所需的机器,当然伪分布式除外. 简单记录下虚拟机环境的创建过程,Mac上常用的虚拟机VMware Fusion. 虚拟机资源库中新建虚拟机: 选 ...

  7. Scrapy 教程(四)-命令

    scrapy 没有界面,需要命令行来操作. 非常简单,总共也就十四五个命令,分为全局命令和项目命令. 全局命令 在哪都能用 常用命令 scrapy startproject name 创建项目/工程 ...

  8. 搜索专题: HDU1242 Rescue

    Rescue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Sub ...

  9. P4050 [JSOI2007]麻将

    传送门 怎么好像没什么人写 $dp$ ...? 设 $f[i][j][k][0/1]$ 表示当前处理完前 $1$ 到 $i$ 的数,上一位开始的顺子有 $j$ 个,当前位开始的顺子有 $k$ 个,是否 ...

  10. 绝对定位left:50% 隐式设置了宽度

    绝对定位left:50% 隐式设置了宽度 不定宽高的盒子如何在父盒子中垂直居中,我们常做的一种方式便是 left: 50%; top: 50%; transform: translate(-50%, ...