算法笔记上能踩的坑都踩了。

#include<iostream>
using namespace std;
float a[1001];//至少1000个位置
int main(){
int n,cnt=0,aa;
float bb;
cin>>n;
for(int i=0;i<n;i++){
cin>>aa>>bb;
if(a[aa]==0)cnt++;
a[aa]+=bb;
}
cin>>n;
for(int i=0;i<n;i++){
cin>>aa>>bb;
if(a[aa]==0)cnt++;
a[aa]+=bb;
if(a[aa]==0)cnt--;//考虑会不会被抵消
}
cout<<cnt;//这里少输出一个“ ”
for(int i=1000;i>=0;i--){
if(a[i]!=0){
printf(" %d %.1f",i,a[i]);//这里都是 “ ”+i+a[i]不就没有格式错误了嘛,太死脑筋了
}
}
}

  

1002 A+B for Polynomials (25分) 格式错误的更多相关文章

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

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

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

  3. 1002 A+B for Polynomials (25分)

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

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

  5. 【PAT甲级】1002 A+B for Polynomials (25 分)

    题意:给出两个多项式,计算两个多项式的和,并以指数从大到小输出多项式的指数个数,指数和系数. AAAAAccepted code: #include<bits/stdc++.h> usin ...

  6. P1002 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 polyn ...

  7. PAT 1009 Product of Polynomials (25分) 指数做数组下标,系数做值

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

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

  9. PAT 1002. A+B for Polynomials (25) 简单模拟

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

随机推荐

  1. NoSql非关系型数据库之MongoDB应用(二):安装MongoDB可视化工具

    业精于勤,荒于嬉:行成于思,毁于随. 我们上次说到NoSql非关系型数据库之MongoDB应用(一):安装MongoDB服务 这次我们介绍安装  NoSQL Manager for MongoDB 可 ...

  2. ansible 任务执行

    ansible 任务执行模式 Ansible 系统由控制主机对被管节点的操作方式可分为两类,即adhoc和playbook: ad-hoc模式(点对点模式)• ad-hoc模式(点对点模式) 使用单个 ...

  3. fastposter发布1.4.2 跨语言的海报生成器

    fastposter发布1.4.2 跨语言的海报生成器 fastposter发布1.4.2 跨语言的海报生成器,一分钟完成海报开发 future: 完善docker镜像 引入异步asyncio 升级p ...

  4. Activiti7 与 Spring Boot 及 Spring Security 整合 踩坑记录

    1.  前言 实话实说,网上关于Activiti的教程千篇一律,有参考价值的不多.很多都是老早以前写的,基本都是直接照搬官方提供的示例,要么就是用单元测试跑一下,要么排除Spring Security ...

  5. ESP32-websocket笔记

    基于ESP-IDF4.1 #include <stdio.h> #include "esp_wifi.h" #include "esp_system.h&qu ...

  6. 开发必备linux命令大全-稳赚不亏

    我们的服务一般都是在linux系统运行,因此了解一些关于linux命令是必须.接下来将一一详细介绍一些常用的linux的命令 文件操作 远程登录与操作 磁盘挂载 进程管理 启动和结束 系统性能参数查看 ...

  7. 【BZOJ 4771】七彩树

    一直TLE的原因竟然是数组开太大了导致\(memset\)清空耗时超限,亏我还调了1天啊(T^T) 题目大意 给定一颗树,每个节点都有一个颜色,要求多次询问某个节点\(x\)的子树中深度不超过\(d\ ...

  8. 洛谷 P4008 [NOI2003]文本编辑器

    先推广一下 求赞 我们考虑这样的一个问题 给你一个序列,要求你支持插入,删除,查询单点值 如果用数组,查询O(1),插入删除最坏O(n) 如果用链表,插入删除O(1),查询最坏O(n) 如果用平衡树- ...

  9. PXE高效批量网络装机

    PXE高效批量网络装机               一.PXE概述                1)PXE (Preboot eXcution Environment)               ...

  10. endless 如何实现不停机重启 Go 程序?

    转载请声明出处哦~,本篇文章发布于luozhiyun的博客:https://www.luozhiyun.com/archives/584 前几篇文章讲解了如何实现一个高效的 HTTP 服务,这次我们来 ...