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 分析:简单题.相乘时指数相加,系数相乘即可,输出时按指数从高到低的顺序.注意点:多项式相 ...
随机推荐
- Reflection01_获取Class对象
1.java 代码: package reflectionZ; public class TreflectionZ { public static void main(String[] args) t ...
- Mongodb笔记(三)user && aggregate && mapReduce
版本:mongodb3.4. User: mongodb使用验证登录:默认不开启,mongod中使用--auth开启: mongod -port=3000 --auth : 基本方法: db.cr ...
- poj3683 2 -sat输出路径
tarjan缩点,拓扑排序染色输出(貌似挑战上面没有拓扑啊,而且这样写还过了= =) 主要是找s,t,d,三者之间的关系,找出合取范式这题就很容易了 #include<map> #incl ...
- mongDB网址
http://www.cnblogs.com/huangxincheng/archive/2012/02/18/2356595.html
- [转载]Java给word中的table赋值
一.准备工作: 下载PageOffice for Java:http://www.zhuozhengsoft.com/dowm/ 二. 实现方法: 要调用PageOffice操作Word中的tabl ...
- WordCounter Python实现
<!doctype html>博客.md p:first-child, #write > ul:first-child, #write > ol:first-child, #w ...
- springmvc 请求和响应的json和Object的转换
就是两个注解的使用@RequestBody和@ResponseBody注解的使用,然后springmvc解析进行转换然后注入 例子: @RequestMapping("/...") ...
- PostgreSQL.conf文件配置详解[转]
一.连接配置与安全认证 1.连接Connection Settings listen_addresses (string) 这个参数只有在启动数据库时,才能被设置.它指定数据库用来监听客户端连接的 ...
- Android Broadcast 和 BroadcastReceiver的权限机制
在Android应用开发中,有时会遇到以下两种情况, 1. 一些敏感的广播并不想让第三方的应用收到 : 2. 要限制自己的Receiver接收某广播来源,避免被恶意的同样的ACTION的广播所干扰. ...
- TensorFlow官网访问不了
相信很多搞深度学习的小伙伴最近都为访问不了 TensorFlow官网 而苦恼吧!虽然网上也给出了一些方法,但是却缺少一个很重要的步骤.接下来,我就给大家讲解一个完整的过程,大牛绕过. 1.更改Host ...