A1009
两个多项式的乘积
两个数组,一个放多项式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的更多相关文章
- 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 ...
- PTA A1009&A1010
第五天 A1009 Product of Polynomials (25 分) 题目内容 This time, you are supposed to find A×B where A and B a ...
- A1009. Product of Polynomials
This time, you are supposed to find A*B where A and B are two polynomials. Input Specification: Each ...
- 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 ...
- PAT A1009 Product of Polynomials(25)
课本AC代码 #include <cstdio> struct Poly { int exp;//指数 double cof; } poly[1001];//第一个多项式 double a ...
- PAT甲级——A1009 Product of Polynomials
This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: Each ...
- PAT/简单模拟习题集(二)
B1018. 锤子剪刀布 (20) Discription: 大家应该都会玩"锤子剪刀布"的游戏:两人同时给出手势,胜负规则如图所示: 现给出两人的交锋记录,请统计双方的胜.平.负 ...
- iot表和heap表排序规则不同
SQL> select * from (select * from t1 order by id ) where rownum<20; ID A1 A2 A3 ---------- --- ...
- Oracle 排序规则
<pre name="code" class="html">SQL> select * from t1 where id>=1 and ...
随机推荐
- 基于原生XMLHttpRequest封装
用了一段时间的Ajax,感觉有很多的不足之处,于是就封装原生了 XMLHttpRequest . 废话不多说,直接上代码. var http = function () { 'use strict'; ...
- 【RequestContext】关于RequestContext的一些小心得
版权声明:随意转载,注明出处 https://blog.csdn.net/River_Continent/article/details/77511389后台传参,一直是一个比较重要的地方,如果涉及W ...
- IntelliJ IDEA调试时,格式化显示日期变量
格式化前: 格式化后: new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this); 入门常用知识: Ct ...
- 深入理解java:1.1.1. 反射机制
反射 到底什么是反射(Reflection)呢? 反射有时候也被称为内省(Introspection),事实上,反射,就是一种内省的方式, Java不允许在运行时改变程序结构或类型变量的结构,但它允许 ...
- @Scheduled(cron = "0/5 * * * * *")将时间改为配置
有两种方法:第一种当然你可以把Scheduled写到xml文件中进行配置. 第二种在你的类前面添加 此处讲解第二种写法 第二种在你的类前面添加@PropertySource("classpa ...
- [19/09/08-星期日] Python的几个概念和语法
一.表达式.语句.程序.函数 1.表达式 就是一个类似于数学公式的东西 ,比如:10 + 5 8 - 4:表达式一般仅仅用了计算一些结果,不会对程序产生实质性的影响 如果在交互模式中输入一个表达式,解 ...
- 本地项目代码上传至github
初始化本地目录:git init cd到个人本地项目代码文件目录下,执行git init命令 添加项目文件到本地仓库:git add . git commit -m "提交说明" ...
- Windows Server 2012 上安装 dotNET Framework v3.5
Windows Server 2012不能直接运行dotNET Framework v3.5安装程序进行安装,系统提供通过服务器管理器的添加功能和角色向导进行安装. 安装的前几个步骤再这里略去,在默认 ...
- zebra代码分析
http://blog.csdn.net/xuyanbo2008/article/details/7439738
- 豆壳CMS本地安装教程
DouPHP安装教程 一.下载DouPHP程序. 解压后得到三个文件夹 将upload文件夹里面的内容复制到wamp的www的文件夹. 二.打开浏览器,输入127.0.0.1. 勾选后选择下一步 注意 ...