浙大 PAT 甲级1009
1009. Product of Polynomials (25)
This time, you are supposed to find A*B where A and B are two polynomials.
Input Specification:
Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial: K N1 aN1 N2 aN2 ... NK aNK, where K is the number of nonzero terms in the polynomial, Ni and aNi (i=1, 2, ..., K) are the exponents and coefficients, respectively. It is given that 1 <= K <= 10, 0 <= NK < ... < N2 < N1 <=1000.
Output Specification:
For each test case you should output the product of A and B in one line, with the same format as the input. Notice that there must be NO extra space at the end of each line. Please be accurate up to 1 decimal place.
Sample Input
2 1 2.4 0 3.2 2 2 1.5 1 0.5
Sample Output
3 3 3.6 2 6.0 1 1.6
#include<stdio.h>
int main(){double a[1001]={0.0},b[2001]={0.0},t; //开两个数组,前一个存第一个多项式,下标为次数,值为系数, 后一个要大一些防止越界,并且直接存储结果。 int n1,n2,m,n,i,j;scanf("%d",&n1);for(i=0;i<n1;i++){scanf("%d %lf",&m,&t);a[m]=t;}scanf("%d",&n2);for(i=0;i<n2;i++){scanf("%d %lf",&m,&t);for(j=0;j<1001;j++){if(a[j]!=0.0){b[m+j]+=a[j]*t; //这里就是模拟多项式乘法的关键!! }}}j=0;for(i=0;i<2001;i++){if(b[i]!=0.0)j++;}printf("%d",j);for(i=2000;i>=0;i--){if(b[i]!=0.0)printf(" %d %.1lf",i,b[i]);}return 0;
}
浙大 PAT 甲级1009相关推荐
- PAT甲级1009 Product of Polynomials:[C++题解]多项式乘法、高精度乘法
文章目录 题目分析 题目链接 题目分析 多项用一个数组来表示,数组下标表示多项式的次幂,存的内容表示多项式的系数. 然后用两重循环来计算多项式的乘法: for i : 第二个式子for j:第一个式子 ...
- PAT甲级1009 Product of Polynomials (25分)
PAT甲级1009 Product of Polynomials (25分) 题目: 题目分析:和之前有一道多项式相加很像,注意点是不仅仅数组系数会变,还可能会出现之前没有的指数,因此要开2001大小 ...
- 浙大PAT甲级1040
浙大PAT甲级1040 原题 问题分析 原题 1040 Longest Symmetric String (25 分) Given a string, you are supposed to outp ...
- PAT——甲级1009:Product of Polynomials;乙级1041:考试座位号;乙级1004:成绩排名...
题目 1009 Product of Polynomials (25 point(s)) This time, you are supposed to find A×B where A and B a ...
- 浙大PAT甲级1019. General Palindromic Number (20)
1019. General Palindromic Number (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
- PAT甲级 -- 1009 Product of Polynomials (25 分)
This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: Each ...
- 【PAT - 甲级1009】Product of Polynomials (25分)(模拟,细节)
题干: This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: ...
- 浙大PAT甲级1027. Colors in Mars (20)
1027. Colors in Mars (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue People ...
- 浙大PAT甲级1006
1006. Sign In and Sign Out (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...
最新文章
- Java 实现MapReduce函数
- fdisk命令非交互模式及parted的mkpart命令第一个参数说明
- Hex-Rays.Decompiler ...
- 修改Apache的默认站点目录的方法,需要的朋友可以参考下
- 一文详解CSS常见的五大布局
- 数据结构与算法--举例分析法- 栈的压入弹出序列
- oracle通信通道的文件结尾_ORA-03113:通信通道的文件结尾解决
- leetcode132. 分割回文串 II(dp)
- cocoscreator editbox 只允许数字_用Cocos做一个数字调节框
- 大数据解密之你的同事都跳槽到了哪些公司
- 01背包问题笔记(转载)
- Linq to xml:检索
- fireworks切图
- 深蓝词库转换2.0发布——支持仓颉、注音、五笔、郑码、二笔等
- 如何让双十一数据大屏讲出故事?设计有口诀
- Python数据分析师使用低代码Streamlit实现Web数据可视化方法——Plotly可视化基础篇
- Elastic-Job (二)实现Dataflow作业
- 2023年全国最新二级建造师精选真题及答案26
- matlab冒号分号区别,matlab : 关于冒号 用法大全以及实例
- TM4C KEIL模板建立
热门文章
- 比特币市值占比达到年内高点
- Axure中后台管理信息系统通用原型方案 /框架模板/数据仪表/团队协作/会员管理/电商系统/资金统计/数据监控/销量统计/订单管理/客户管理/团队协作/职务管理/业务信息/员工管理/即时通讯
- 前后端数据交互之前端传值到后台
- springboot中配置过滤器以及可能出现的问题
- 行高引起的行内块级元素间距
- LeetCode -- Sort List
- Python——eventlet.wsgi
- HTML5学习之视频与音频(三)
- VS 2008的JavaScript代码提示功能 (学习老赵视频的笔记)
- WebBrowser控件 打印2