题意:模拟多项式相乘

思路:略。有一个注意点,题目中说指数最大为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. Kubernetes源码之旅:从kubectl到API Server

    概述: Kubernetes项目目前依然延续着之前爆炸式的扩张.急需能够理解Kubernetes原理并且贡献代码的软件开发者.学习Kubernetes源码并不容易.Kubernetes是使用相对年轻的 ...

  2. split方法的使用

    // 分隔竖线 String[] param = text.split("\\|");   //分隔问号 String name = singleResource.get(&quo ...

  3. Linux系列—策略路由、ip rule、ip route

    早期在管理Linux系统的网络时,常使用ifconfig及route之类的命令,不过如果你准备开始使用Linux强大的基于策略的路由机制,那么,就请不要使用这类工具了,因为这类工具根本无法用于功能强大 ...

  4. Prism开发人员指南5-WPF开发 文档翻译(纯汉语版)

    2014四月       Prism以示例和文档的形式帮助你更简单的设计丰富灵活易维护的WPF程序.其中使用的设计模式体现了一些重要的设计原则,例如分离关注点和松耦合,Prism帮助你利用松耦合组件设 ...

  5. Audio/Movie/Image

    Audio 1. 引入AVFoundation 库,此库用于处理音频的播放. > 使用AVAudioPlayer 播放音频,此类只能播放本地音频文件.对于流媒体(边下边播)的播放使用第三方框架实 ...

  6. react: menuService

    1.获取菜单对象 static findCurrentItem(items, currentState, currentItem) { _.forEach(items, function (item) ...

  7. 首次尝试LINUX下的ssh命令:登录和退出

    1:我现在本机安装了centos虚拟机,然后在windows桌面下使用SecureCRT ssh客户端登录我的本地虚拟机,再然后 通过centos下的ssh命令登录局域网内测试机192.168.0.1 ...

  8. shell 中并发执行

    http://bbs.51cto.com/thread-1104907-1-1.html http://www.51testing.com/html/28/116228-238978.html htt ...

  9. 【学习】Git和Github菜鸟入门

    Git 是一个开源的分布式版本控制系统,用以有效.高速的处理从很小到非常大的项目版本管理. 目录(自己创建吧) 生成ssh密钥:ssh-keygen -t rsa -C "邮箱" ...

  10. WPF XMAL获取元素的父元素,子元素

    /// 获得指定元素的父元素 /// </summary> /// <typeparam name="T">指定页面元素</typeparam> ...