两个多项式的乘积

两个数组,一个放多项式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. NIO组件之buffer

    Java NIO指的是new IO ,相对OIO,也称non-blocking IO,对应四种基本IO类型中的IO多路复用,主要有有三大核心组件,Channel(管道),Buffer(缓冲区),sel ...

  2. PHP 数组函数 内部指针

    current( &$arr ) 每个数组的当前单元,初始值的 数组的第一个单元next ( &$arr ) 返回数组中的下一个单元 , 如果没值则返回falshprev ( & ...

  3. Linux安装python3.6 和pip

    Linux下安装Python3.6和第三方库   如果本机安装了python2,尽量不要管他,使用python3运行python脚本就好,因为可能有程序依赖目前的python2环境, 比如yum!!! ...

  4. Scratch少儿编程系列:(八)演奏简单音乐

    一.程序说明 本程序,用来演奏简单音乐. 二.制作过程 1. 场景和角色的选择 场景选择“音乐和舞蹈”主题下的“party root”,角色沿用默认角色,如下图: 选择后效果如下图: 2. 切换到“脚 ...

  5. ubutnu同时安装OpenCV2和OpenCV3及contrib

    1.OpenCV2源码安装 安装依赖项 sudo apt-get install build-essential //build-essential是c语言的开发包,包含了gcc make gdb和l ...

  6. 使用itchat获取微信好友的男女比例

    # 使用itchat获取微信好友的男女比例 import itchat itchat.auto_login(hotReload=True) friends = itchat.get_friends(u ...

  7. js 中 json.stringfy()将对象、数组转换成字符串

    json.stringfy()将对象.数组转换成字符串 var student = new Object(); student.name = "Lanny"; student.ag ...

  8. C++智能指针 原理、使用与实现

    目录 理解智能指针的原理 智能指针的使用 智能指针的设计和实现 1.智能指针的作用 C++程序设计中使用堆内存是非常频繁的操作,堆内存的申请和释放都由程序员自己管理.程序员自己管理堆内存可以提高了程序 ...

  9. [转帖]TLS握手:回顾1.2、迎接1.3

    TLS握手:回顾1.2.迎接1.3 novsec2019-05-10共26541人围观 ,发现 2 个不明物体网络安全 *本文原创作者:novsec,本文属于FreeBuf原创奖励计划,未经许可禁止转 ...

  10. mysql自动生成my.cnf文件

     http://imysql.com/my-cnf-wizard.html