参考: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. 沉淀再出发:xml的意义和存在的价值

    沉淀再出发:xml的意义和存在的价值 一.前言 学习了那么多的语言.框架.语法和基础知识,我们对于数据的理解或许有了一定的认识,但是如何描述.包装.传输.存储数据的手法和流程我们了解的或许并不多,其中 ...

  2. 等待事件P1 P2 P3含义

    从以下两个视图中查到的session中,有P1,P2,P3参数select * from v$sessionselect * from v$session_waitselect * from v$se ...

  3. 软件cs页面分辨率测试

    1.为什么软件要进行分辨率兼容性测试 用户的环境可能大多数是主流的分辨率,如1024x768,1366x700,但是我们还是遇到了一些使用上网本的用户,他的上网本分辨率是1024x600,由于我们的软 ...

  4. 微信小程序及各种平台对接常用可逆加密算法aes256

    不同程序之间经常会交换数据,我们经常采用的套路是: 假设要传输的信息是json,我们假设其为json_data,通过http传递信息为 json_data_encode=json_data&s ...

  5. [BZOJ 3514]Codechef MARCH14 GERALD07加强版 (CHEF AND GRAPH QUERIES)

    [BZOJ3514] Codechef MARCH14 GERALD07加强版 (CHEF AND GRAPH QUERIES) 题意 \(N\) 个点 \(M\) 条边的无向图,\(K\) 次询问保 ...

  6. canvas小球 时间demo

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  7. lock与sychronized关键字

    1. lock与sychronized关键字的区别 (1) Lock是一个接口,而synchronized是Java中的关键字,synchronized是内置的语言实现,Lock是代码层面的实现.(2 ...

  8. 【[HEOI2014]大工程 】

    可能是虚树板子题了 首先先把虚树建出来,但是这里和那道虚树的入门题不一样,这里所有的询问点都得在虚树里,所以不会存在那种直接不如栈的点 之后我们考虑一下这个三个要求的东西 第一个操作我们需要统计虚树上 ...

  9. 【[NOI2010]超级钢琴】

    我竟然又在写主席树 现在可是九月啦,我却还在写这种noip不可能考的算法 我觉得我真的要凉 题意很明确,就是给你一个序列,让从中选择\(k\)段连续的序列,长度必须大于等于\(L\)小于等于\(R\) ...

  10. VC++ UDP网络控制台程序

     采用的是VC2008,控制台应用程序,使用UDP编写. 1.服务端代码 //UDPServer.cpp #include <WinSock2.h> #include <stdio. ...