两个多项式的乘积

两个数组,一个放多项式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. 什么是SLF,PSL,MLF,SLO?

    受国际经济金融形势不确定性增强以及各种影响流动性的因素波动较大影响,近年来我国银行体系短期流动性供求的波动性有所加大,尤其是当多个因素相互叠加或市场预期发生变化时,有可能出现市场短期资金供求缺口难以通 ...

  2. Neither abstinence nor excess ever renders man happy

    inch.n. 英寸 courageous.adj.勇敢的 porcelain.n.瓷器 adj.脆的 inventor. n. 发明者 trivial.adj. 不重要的 grove.n.小树林,果 ...

  3. tensorflow学习之tf.placeholder

    placeholder函数相当于一个占位符,tf.placeholder(dtype, shape=None, name=None) dtype:数据类型.常用的是tf.float32,tf.floa ...

  4. TensorFlow2.0矩阵与向量的加减乘

    1.矩阵加法使用 a = np.random.random((3,3))b = np.random.randint(0,9,(3,3)) ad = tf.add(a,b) 2.矩阵乘法注意 # ten ...

  5. webpack打包错误 ERROR in multi ./src/main.js ./dist/bundle.js

    webpack打包错误 ERROR in multi ./src/main.js ./dist/bundle.js:https://www.jianshu.com/p/a55fb5bf75e1

  6. Android使用adb抓完整Log

    前言     最新项目里一直在做 Android RIL 方面的研究,非常最终项目还是未能解决通信底层模块的问题,但是在使用adb抓log上还是有一些收获的,这里记录一下.   Log分类     A ...

  7. C#修改电脑桌面图

    win32helper public class Win32Helper { [DllImport("user32.dll", EntryPoint = "SystemP ...

  8. 02.AutoMapper 之扁平化(Flattening)

    https://www.jianshu.com/p/65099590c930   扁平化(Flattening) 对象映射器的常见用法是将一个复杂对象模型扁平化为一个简单模型.例如您有一个以下复杂模型 ...

  9. Windows 环境下安装redis 及其PHP Redis扩展

    1.安装Redis (1)这里选择在github官网上下载Redis,地址:Redis下载地址 下载压缩包(如下图),并解压到本地目录,我放在D:\redis (2)验证Redis安装是否成功打开命令 ...

  10. Spark-Streaming获取kafka数据的两种方式:Receiver与Direct的方式

    简单理解为:Receiver方式是通过zookeeper来连接kafka队列,Direct方式是直接连接到kafka的节点上获取数据 Receiver 使用Kafka的高层次Consumer API来 ...