参考:https://www.jianshu.com/p/e7a3ee0f82d9

 #include<bits/stdc++.h>
using namespace std;
const int N=1e6+;
double xi[N];
struct node
{
int zhi;//指数
double xi;//系数
}noa[],nob[];
int main()
{
int na,nb;
cin>>na;
for (int i=;i<na;i++)
{
cin>>noa[i].zhi;
cin>>noa[i].xi;
}
cin>>nb;
for (int i=;i<nb;i++)
{
cin>>nob[i].zhi;
cin>>nob[i].xi;
}
double tempxi;//临时系数
int tempzhi,nc=;//临时指数
for (int i=;i<na;i++)
{
for (int j=;j<nb;j++)
{
tempzhi=noa[i].zhi+nob[j].zhi;
tempxi=noa[i].xi*nob[j].xi;
// if (xi[tempzhi]==(double)0)//在计算过程中,某一指数项的系数有可能暂时为0后又不为0,所以不能用
// { //这段代码来计数!!
// nc++;
// }
xi[tempzhi]+=tempxi;
}
}
for (int i=N;i>=;i--)
{
if (xi[i]!=(double))
{
nc++;
}
}
cout<<nc;
for (int i=N;i>=;i--)
{
if (xi[i]!=(double))
{
printf(" %d %.1f",i,xi[i]);
}
}
cout<<endl; return ;
}

PAT-A 1009. Product of Polynomials的更多相关文章

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

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

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

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

  4. PAT甲级——1009 Product of Polynomials

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

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

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

  6. PAT Advanced 1009 Product of Polynomials (25 分)(vector删除元素用的是erase)

    This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: Each ...

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

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

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

  10. PATA 1009. Product of Polynomials (25)

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

随机推荐

  1. 性状、生成器、闭包、OPcache【Modern PHP】

    目录 性状 Trait 生成器 闭包 Zend OPcache PHP发展这么多年,技术.架构都已经革新,了解现代PHP很重要,最近在看Model PHP这本书,系统的了解下PHP相关的概念. 性状 ...

  2. FOR YOU

    给你 作者:余秀华 一家朴素的茶馆, 面前目光朴素的你皆为我喜欢 你的胡子,昨夜辗转的面色让我忧伤 我想带给你的,一路已经丢失得差不多 除了窗外凋谢的春色 遇见你以后,你不停地爱别人,一个接一个 我没 ...

  3. Java对文件的读取方式以及它们的优缺点

    Java常用的对文件的读取方式基本包括: BufferedReader -> readLine(): 按行读取文件,直到读取内容==null FileInputStream -> read ...

  4. Django 发送html邮件

    转载于: http://blog.sina.com.cn/s/blog_76e94d2101011bxd.html   django中发送html邮件:   #mailer.py   # -*- co ...

  5. BZOJ2599:[IOI2011]Race(点分治)

    Description 给一棵树,每条边有权.求一条简单路径,权值和等于K,且边的数量最小.N <= 200000, K <= 1000000 Input 第一行 两个整数 n, k 第二 ...

  6. [19/04/23-星期二] GOF23_创建型模式(工厂模式、抽象工厂模式)

    一.工厂模式(分为:简单工厂模式.工厂方法模式.抽象工厂模式) 实现了创建者和调用者的分离 核心本质:1.实例化对象,用工厂方法代替new操作:2.将选择实现类.创建对象统一管理和控制,从而将调用者跟 ...

  7. 自定义ViewPagerIndicator-视图指示器

    ViewPagerIndicator.java public class ViewPagerIndicator extends LinearLayout { private Paint mPaint; ...

  8. 6 spark 存储体系

    6.1 block存储体系 存储体系架构图 6.2 block 信息信息管理器 6.2.2 bock锁的实现 6.3 磁盘block管理 /* * Licensed to the Apache Sof ...

  9. SpringBoot实战(九)之Validator

    表单验证,是最为常见的,今天演示的是利用hibernate-validtor进行校验,有的时候,虽然前端方面通过jQuery或者require.js校验框架进行校验,可以减轻服务器的压力和改善用户体验 ...

  10. iostat查看系统的IO负载情况

    1.安装iostat工具: [root@localhost ~]# yum -y install sysstat 2.通过命令查看IO情况: %idle如果小于%70的话,说明磁盘的IO负载压力已经很 ...