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 分析:简单题.相乘时指数相加,系数相乘即可,输出时按指数从高到低的顺序.注意点:多项式相 ...
随机推荐
- Android并发编程之白话文详解Future,FutureTask和Callable
从最简单的说起Thread和Runnable 说到并发编程,就一定是多个线程并发执行任务.那么并发编程的基础是什么呢?没错那就是Thread了.一个Thread可以执行一个Runnable类型的对象. ...
- Netty原理
1. Netty简介Netty是一个高性能.异步事件驱动的NIO框架,基于JAVA NIO提供的API实现.它提供了对TCP.UDP和文件传输的支持,作为一个异步NIO框架,Netty的所有IO操作都 ...
- CodeForces - 767C
花了6个小时,终于成功ac...... 两边dfs,第一遍求子树和,第二遍判断有没有2*t[s]/3和t[s]/3,因为要求的节点可能是在同一条线上,同时要有2*t[s]/3和t[s]/3的情况,且2 ...
- 51nod 1639 递推
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1639 1639 绑鞋带 基准时间限制:1 秒 空间限制:131072 K ...
- 有云Ceph课堂:使用CivetWeb快速搭建RGW
转自:https://www.ustack.com/blog/civetweb/ 优秀的开源项目正在改变传统IT,OpenStack名头最响,已经成为了IaaS的事实标准.Ceph同样颇有建树,通过其 ...
- ASM9260T开发板使用
ifconfig eth0 192.168.1.66 netmask 255.255.255.0 up //设备iproute add default gw 192.168.1.1 //添加网 ...
- 使用Jenkins自动编译我的 java 项目 git maven jenkins
之前的项目已经将jenkins部署好,现在添加maven项目 准备工作 安装插件 Git plugin Publish Over SSH 全局设置 key: 是 linux服务器的私钥 Global ...
- 用php实现四种常见的排序算法
几种常见的排序 排序是一个程序员的基本功,对于初级phper,更是可以通过排序算法来锻炼自己的思维能力. 所谓排序,就是对一组数据,按照某个顺序排列的过程.下面就总结四种常用的php排序算法,分别是冒 ...
- mac/linux ssh 免密码登陆配置及错误处理
先说一下,mac 和linux 的设置方法是一样的 一般做法可以参照http://www.tuicool.com/articles/i6nyei 第一步:生成密钥.在终端下执行命令: ssh-kege ...
- Java 对称加密
最近在做一个用户 token 功能,学习了加密相关 AES/DES.RSA 等.其中涉及一个对称和非对称加密问题.对称加密虽然没有非对称加密那样安全性高,但好处是加密速度快,但某些场合还是可以选择使用 ...