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 分析:简单题.相乘时指数相加,系数相乘即可,输出时按指数从高到低的顺序.注意点:多项式相 ...
随机推荐
- 文件IO大纲
文件流与文件描述符的区别 a) 任何进程在运行时都默认打开3个流对象,(stdin, stdout, stderr)它们都有对应的文件描述符,其文件描述符分别为0,1,2,以后打开的文件描述符的值一般 ...
- 在web.xml中配置spring配置文件的路径
<context-param> <param-name>contextConfigLocation</param-name> <param-v ...
- SpringMVC4整合CXF发布WebService
SpringMVC4整合CXF发布WebService版本:SpringMVC 4.1.6,CXF 3.1.0项目管理:apache-maven-3.3.3 pom.xml <project x ...
- day5-shutil模块
一.概述 我们通过python操作文件时,除正常读写操作外,有时还需要进行拷贝.删除.打包等操作,虽然os模块提供了部分功能,但还是不够完善,这里要讲讲专业的高级的文件,文件夹,压缩包处理模块shut ...
- mysql 字段属性 与 排序
mysql中常见的数据类型:varchar(n).float.int(n).bigint(n).date.datetime.text 字段属性 默认值:DEFAULT '默认值' 非空:NOT NUL ...
- 【lightoj-1055】Going Together(BFS)
链接:http://www.lightoj.com/volume_showproblem.php?problem=1055 类似推箱子的游戏,一条命令可以让abc三个小人同时移动,但是出界或者撞墙是不 ...
- IOS对存放对象的数组排序
我们开发的每个程序都会使用到一些数据,而这些数据一般被封装在一个自定义的类中.例如一个音乐程序可能会有一个Song类,聊天程序则又一个 Friend类,点菜程序会有一个Recipe类等.有时候我们希望 ...
- Electron中git, npm,webpack使用
开始学习Electron的时候用到git, 记录学习一下, 学习地址是: https://zhuanlan.zhihu.com/p/20225295?columnSlug=FrontendMagazi ...
- 2——FFMPEG之协议(文件)操作----AVIOContext, URLContext, URLProtocol
协议操作对象结构: 协议(文件)操作的顶层结构是AVIOContext,这个对象实现了带缓冲的读写操作:FFMPEG的输入对象AVFormat的pb字段指向一个AVIOContext. AVIOCon ...
- 【MFC】MoveWindow();函数使用详解
摘自:http://blog.csdn.net/yjkwf/article/details/5281207 CWnd::MoveWindow 详解 2010-02-02 16:08 3432人阅读 评 ...