1009. Product of Polynomials
来源:互联网 发布:parsley.js 中文提示 编辑:程序博客网 时间:2024/05/01 12:45
多项式的积
http://pat.zju.edu.cn/contests/pat-a-practise/1009
1、理解该形式下,多项式积的定义
2、数据格式,浮点输入输出
3、使用数组先清空,谨慎
#include <stdio.h>#include <string.h>int main(){int k,i,j,c; //多项式的项,不超过10项,c,e暂存输入的指数与系数double e;double exp1[1001]; //保存指数相应系数,最多1000个指数,浮点double exp2[1001];double ans[2001]; //保存最终结果,每项的系数,1000次*1000次=2000次方memset(exp1,0,sizeof(exp1));memset(exp2,0,sizeof(exp2));memset(ans,0,sizeof(ans));scanf("%d",&k);for (i=0;i<k;i++) //输入第一个多项式{ scanf("%d%lf",&c,&e); exp1[c]=e;}scanf("%d",&k);for (i=0;i<k;i++) //输入第二个多项式{scanf("%d%lf",&c,&e);exp2[c]=e;}for (i=0;i<=1000;i++){for (j=0;j<=1000;j++){ans[i+j]+=exp1[i]*exp2[j];}}int x=0;for (i=0;i<=2000;i++){if (ans[i]){x++;}}printf("%d",x); for (i=2000;i>=0;i--) {if (ans[i]){printf(" %d %.1lf",i,ans[i]);} }printf("\n");return 0;}
- 1009. Product of Polynomials
- 1009. Product of Polynomials
- 1009. Product of Polynomials
- 1009.Product of Polynomials
- 1009. Product of Polynomials
- 1009. Product of Polynomials
- 1009. Product of Polynomials
- 1009. Product of Polynomials
- 1009. Product of Polynomials
- 1009. Product of Polynomials
- 1009. Product of Polynomials
- 1009. Product of Polynomials (25)
- 【PAT】1009. Product of Polynomials
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 1009. Product of Polynomials (25)
- 第二篇:Cydia添加源和安装软件
- Linux系统NFS服务器的配置方法
- jsp:由rs.last()方法不可用,学习ResultSet游标笔记 .
- OpenNI 2 對 Kinect 的支援
- android通过wifi进行粗略定位(google maps)操作办法
- 1009. Product of Polynomials
- 深入理解JavaScript系列(2):揭秘命名函数表达式
- ABAP "FOR ALL ENTRIES IN" 使用指南
- struts 向后台传值
- 使用C#选择文件夹、打开文件夹、选择文件或者如何使用C#选择文件夹
- Linux下配置安装NFS
- Matrix学习2、Matrix的基本三种变换之Scale
- 【VC++编译 常见错误】Warning、Error、Fatal Error、Link
- 如何在Linux中查看进程占用内存情况