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 分析:简单题.相乘时指数相加,系数相乘即可,输出时按指数从高到低的顺序.注意点:多项式相 ...
随机推荐
- 如何让Myeclipse已经关闭掉的项目不显示出来
一.打开Package Explorer视图,在它的右上角有一个向下的三角图标. 2.点击后选择Filters,在弹出的Filter配置窗口中选中"Closed Projects" ...
- Author Agreement
Dear Editor,We the undersigned declare that this manuscript entitled “文章标题” is original, has not bee ...
- Oracle Package
(转自:http://blog.csdn.net/bbliutao/article/details/9016947) 一.概述包可将一些有联系的对象放在其内部.任何能在块定义部分出现的对象都可以在包中 ...
- Makefile的补充学习2
Makefile中使用通配符(1)* 若干个任意字符(2)? 1个任意字符(3)[] 将[]中的字符依次去和外面的结合匹配 还有个%,也是通配符,表示任意多个字符,和*很相似,但是%一般只用于规则描述 ...
- 多种方式实现滑动p91--105
1.layout方法 2.offsetLeftAndRight()与offsetTopAndBottom()方法 3.LayoutParams(前提是要有父布局,根据父布局的类型决定LayoutPar ...
- 早上来开启eclipse,谁想代码都不见了,猜想是工作空间换了
1.试了下网上说的改eclipse配置文件,不好使,连接地址:http://blog.csdn.net/gnail_oug/article/details/53992580 2.然后看了下 eclip ...
- LeetCode OJ:Count Primes(质数计数)
Count the number of prime numbers less than a non-negative number, n. 计算小于n的质数的个数,当然就要用到大名鼎鼎的筛法了,代码如 ...
- Week07《Java程序设计》第七次作业总结
Week07<Java程序设计>第七次作业总结 1. 本周学习总结 1.1 思维导图:Java图形界面总结 答: 1.2 可选:使用常规方法总结其他上课内容. 答: 1. Swing组件: ...
- 20165210 2017-2018-2《Java程序设计》课程总结
20165210 2017-2018-2<Java程序设计>课程总结 每周作业链接汇总: 预备作业一: 20165210 我期望的师生关系 预备作业二:20165210 学习基础和C语言基 ...
- The Saltwater Room
I opened my eyes last night and saw you in the low light 昨夜我睁开眼,看见你在昏暗的灯光下 Walking down by the bay, ...