1009 Product of Polynomials
题意:模拟多项式相乘
思路:略。有一个注意点,题目中说指数最大为1000,当两个多项式相乘后,指数最大就为2000,这一点不注意会出现段错误。
代码:
#include <cstdio>
;//注意N必须大于等于2000,而不能是1000
struct Term{
double coe;//系数
int exp;//指数
}a[],b[];
int main()
{
//freopen("pat.txt","r",stdin);
int ka,kb;
scanf("%d",&ka);
;i<ka;i++)
scanf("%d%lf",&a[i].exp,&a[i].coe);
scanf("%d",&kb);
;i<kb;i++)
scanf("%d%lf",&b[i].exp,&b[i].coe);
};//下标存放指数,对应的值代表系数
;i<ka;i++){
;j<kb;j++){
int exp=a[i].exp+b[j].exp;
double coe=a[i].coe*b[j].coe;
product[exp]+=coe;
}
}
;
;i<N;i++){
) len++;
}
printf("%d",len);
;i>=;i--){
)
printf(" %d %.1f",i,product[i]);
}
;
}
1009 Product of Polynomials的更多相关文章
- PAT 1009 Product of Polynomials
1009 Product of Polynomials (25 分) This time, you are supposed to find A×B where A and B are two p ...
- PTA (Advanced Level) 1009 Product of Polynomials
1009 Product of Polynomials This time, you are supposed to find A×B where A and B are two polynomial ...
- 1009 Product of Polynomials (25 分)
1009 Product of Polynomials (25 分) This time, you are supposed to find A×B where A and B are two pol ...
- PAT甲 1009. Product of Polynomials (25) 2016-09-09 23:02 96人阅读 评论(0) 收藏
1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...
- PAT 甲级 1009 Product of Polynomials (25)(25 分)(坑比较多,a可能很大,a也有可能是负数,回头再看看)
1009 Product of Polynomials (25)(25 分) This time, you are supposed to find A*B where A and B are two ...
- pat 甲级 1009. Product of Polynomials (25)
1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...
- PATA 1009. Product of Polynomials (25)
1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...
- 1009 Product of Polynomials (25分) 多项式乘法
1009 Product of Polynomials (25分) This time, you are supposed to find A×B where A and B are two po ...
- PAT甲级——1009 Product of Polynomials
PATA1009 Product of Polynomials Output Specification: For each test case you should output the produ ...
- 【PAT】1009. Product of Polynomials (25)
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1009 分析:简单题.相乘时指数相加,系数相乘即可,输出时按指数从高到低的顺序.注意点:多项式相 ...
随机推荐
- 为什么Kubernetes不使用libnetwork
Kubernetes 在 1.0 版本之前就已经有了最初的网络插件.与此同时 Docker 也引入了 libnetwork 和 Container Network Model (CNM).现在 Doc ...
- mybatis学习(2)
select元素. 自定义resultMap,自定义返回. 建表语句如下所示: create table tbl_dept( id ) primary key auto_increment, dept ...
- InflateException:Bin file line #19:Error inflating class MyTextView
InflateException:Bin file line #19:Error inflating class MyTextView 一.错误简介 为了实现TextView的跑马灯效果,我自己写了一 ...
- UVA 1626 区间dp、打印路径
uva 紫书例题,这个区间dp最容易错的应该是(S)这种匹配情况,如果不是题目中给了提示我就忽略了,只想着左右分割忘记了这种特殊的例子. dp[i][j]=MIN{dp[i+1][j-1] | if( ...
- 017对象——对象 get_object_vars get_parent_class is_subclass_of interface_exists
<?php /** */ //get_object_vars($obj) 获得对象的属性,以关联数据形式返回. /*class study{ public $name; public $age; ...
- 探索Javascript 异步编程
在我们日常编码中,需要异步的场景很多,比如读取文件内容.获取远程数据.发送数据到服务端等.因为浏览器环境里Javascript是单线程的,所以异步编程在前端领域尤为重要. 异步的概念 所谓异步,是指当 ...
- js 复制粘贴功能记录
最近工作中需要在前端页面中使用代码完成剪贴板的读写,网上搜索了下相应的资料,记录下... 这个功能有两个办法一个是js方式,一个是使用flash 一.JS方法 1.复制 首先复制的过程分为两步曲,无论 ...
- jsp中的session
浏览器和服务器的异常通话 常用方法 setAttribute(String key,Object value);//设置值 getAttribute(String key); //取值 Invalid ...
- Python探索记(18)——文件File
# @Time : 2017/7/8 21:10 # @Author : 原创作者:谷哥的小弟 # @Site : 博客地址:http://blog.csdn.net/lfdfhl # @DESC : ...
- HTML里 iframe跳转后关闭iframe
if(window != top){ top.location.href = location.href; }