题意:给出两个多项式,计算两个多项式的和,并以指数从大到小输出多项式的指数个数,指数和系数。

AAAAAccepted code:

 #include<bits/stdc++.h>
using namespace std;
double a[];
int main(){
int k;
cin>>k;
int max_n=;
for(int i=;i<=k;++i){
int n;
cin>>n;
double x;
cin>>x;
a[n]+=x;
max_n=max(max_n,n);
}
cin>>k;
for(int i=;i<=k;++i){
int n;
cin>>n;
double x;
cin>>x;
a[n]+=x;
max_n=max(max_n,n);
}
int cnt=;
for(int i=;i<=max_n;++i)
if(a[i])
cnt++;
cout<<cnt;
for(int i=max_n;i>=;--i)
if(a[i])
printf(" %d %.1f",i,a[i]);
return ;
}

【PAT甲级】1002 A+B for Polynomials (25 分)的更多相关文章

  1. PAT甲级 1002 A+B for Polynomials (25)(25 分)

    1002 A+B for Polynomials (25)(25 分) This time, you are supposed to find A+B where A and B are two po ...

  2. PAT 甲级1002 A+B for Polynomials (25)

    1002. A+B for Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue T ...

  3. PAT Advanced 1002 A+B for Polynomials (25 分)(隐藏条件,多项式的系数不能为0)

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

  4. 【PAT甲级】1009 Product of Polynomials (25 分)

    题意: 给出两个多项式,计算两个多项式的积,并以指数从大到小输出多项式的指数个数,指数和系数. trick: 这道题数据未知,导致测试的时候发现不了问题所在. 用set统计非零项时,通过set.siz ...

  5. PAT (Advanced Level) Practice 1002 A+B for Polynomials (25 分) 凌宸1642

    PAT (Advanced Level) Practice 1002 A+B for Polynomials (25 分) 凌宸1642 题目描述: This time, you are suppos ...

  6. PAT甲级:1036 Boys vs Girls (25分)

    PAT甲级:1036 Boys vs Girls (25分) 题干 This time you are asked to tell the difference between the lowest ...

  7. PAT甲级:1089 Insert or Merge (25分)

    PAT甲级:1089 Insert or Merge (25分) 题干 According to Wikipedia: Insertion sort iterates, consuming one i ...

  8. 【PAT】1002. A+B for Polynomials (25)

    1002. A+B for Polynomials (25) This time, you are supposed to find A+B where A and B are two polynom ...

  9. PAT 甲级 1002 A+B for Polynomials (25 分)

    1002 A+B for Polynomials (25 分) This time, you are supposed to find A+B where A and B are two polyno ...

  10. PAT 甲级 1145 Hashing - Average Search Time (25 分)(读不懂题,也没听说过平方探测法解决哈希冲突。。。感觉题目也有点问题)

    1145 Hashing - Average Search Time (25 分)   The task of this problem is simple: insert a sequence of ...

随机推荐

  1. VS2017编写c/c++汇编函数并调用

    首先在VS里面创建个空项目,然后添加汇编文件 .asm,    右键asm文件属性  --- 常规,改成下图的设置  , 从生成中排除改为否, 项类型改为自定义生成工具 然后点确定. 再次右键asm文 ...

  2. 欧拉降幂 (a^t)%c 模板

    #include<bits/stdc++.h> using namespace std; typedef long long ll; ll a,c,p,mod; ]; ll phi(ll ...

  3. oracle创建、删除索引等操作

    1.创建索引 create index 索引名 on 表名(列名); 2.删除索引 drop index 索引名; 3.创建组合索引 create index 索引名 on 表名(列名1,,列名2); ...

  4. ALSA driver基本概念

    https://blog.csdn.net/zyuanyun/article/details/59180272#t6 1.Card For each soundcard, a “card” recor ...

  5. Pascal 错误代码及含义

    DOS 错误代码:1无效DoS功能号 2文件末找到 3路径未找到 4打开文件过多 5禁止文件存取 6无效文件句柄 12无效文件存取代码 15无效驱动器号 16不能删除当前日录 17不能跨驱动器改文件名 ...

  6. JS中的解构

    先看看数组解构: function fn(){ return [1,2,3]; } var [a,b,c] = fn(); console.log(a,b,c); // 1 2 3 var [d,,f ...

  7. awk函数实现将简化IPV6地址补全

    在用awk处理文本时,有些场景需要将简化的IPV6地址补充成完整的IPV6地址,下边函数可简单实现: IPV6地址补全函数 # ipv6地址补全函数 function compipv6(orig_ad ...

  8. 清晰架构(Clean Architecture)的Go微服务: 程序设计

    我使用Go和gRPC创建了一个微服务,并将程序设计和编程的最佳实践应用于该项目. 我写了一系列关于在项目工作中做出的设计决策和取舍的文章,此篇是关于程序设计. 程序的设计遵循清晰架构(Clean Ar ...

  9. 如何在app.js 和其他页面中更改globalData的值

    它不能用this.setData方法更改值,该方法只能更改data:{}对象(而且在app.js中无法使用该方法),因此用app.globalData.isLogin = true;

  10. 4500-X启动到“511K bytes of non-volatile configuration memory”,无法继续?

    在设备做了某些配置后,尤其是升级,重启设备后,发现设备在如下界面卡住,无法进一步进入CLI命令行. Platform Manager: starting in standalone mode (act ...