题意:模拟多项式相乘

思路:略。有一个注意点,题目中说指数最大为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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. pat 甲级 1009. Product of Polynomials (25)

    1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...

  7. PATA 1009. Product of Polynomials (25)

    1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...

  8. 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 ...

  9. PAT甲级——1009 Product of Polynomials

    PATA1009 Product of Polynomials Output Specification: For each test case you should output the produ ...

  10. 【PAT】1009. Product of Polynomials (25)

    题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1009 分析:简单题.相乘时指数相加,系数相乘即可,输出时按指数从高到低的顺序.注意点:多项式相 ...

随机推荐

  1. 对CSS了解-overflow:hidden

    overflow:hidden 列出我在项目中,运用到此属性的例子: (1)暴力清除浮动 <style type="text/css"> .wrap {;backgro ...

  2. mongodb停止遇到shutdownServer failed: unauthorized: this command must run from localhost when running db without auth解决方法

    停止mongodb use admin db.shutdownServer(); mongos> db.shutdownServer(); assert failed : unexpected ...

  3. ARM汇编指令集4

    协处理器cp15操作指令: mcr & mrc •mrc用于读取CP15中的寄存器 •mcr用于写入CP15中的寄存器   什么是协处理器? •SoC内部另一处理核心,协助主CPU实现某些功能 ...

  4. LeetCode OJ:Find Peak Element(寻找峰值元素)

    A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ ...

  5. SpringCloud教程 | 第十三篇: 断路器聚合监控(Hystrix Turbine)

    版权声明:本文为博主原创文章,欢迎转载,转载请注明作者.原文超链接 ,博主地址:http://blog.csdn.net/forezp. http://blog.csdn.net/forezp/art ...

  6. SVN 的搭建及使用(二)VisualSVN Server建立版本库,以及VisualSVN和TortoiseSVN的使用

    上一篇介绍了VisualSVN Server和TortoiseSVN的下载,安装,汉化.这篇介绍一下如何使用VisualSVN Server建立版本库,以及VisualSVN和TortoiseSVN的 ...

  7. margin特性深入分析与总结

    今天写了个小demo,总体不难,但一些细节需要注意: 1)如下图所示,蓝色区域为白色box的padding,橙色区域为每条数据项的margin-bottom,那么如何解决最后一条记录margin-bo ...

  8. less 应用

    链接           变量传入, 实现不同方向的三角形

  9. css3 伪类

    ::selection { 选中后的样式 } 链接 p:only-child     p的父级只有一个p标签 p:only-of-type   p的父级有一个p标签, 但还可以包含其他标签 p:fis ...

  10. NODE 性能优化

    五个手段 “如果你的 node 服务器前面没有 nginx, 那么你可能做错了.”—Bryan Hughes Node.js 是使用 最流行的语言— JavaScript 构建服务器端应用的领先工具 ...