当前位置:网站首页>PAT1002
PAT1002
2022-08-09 11:09:00 【AlanLiu6】
https://pintia.cn/problem-sets/994805342720868352/problems/994805526272000000
这个题竟然无限WA,菜的真实
坑点:和为0的数不输出,题目中说的很隐晦,很容易忽略,在“with the same format as the input.”中说了,输出的格式和输入相同,则输出时,不能输出为0的数
#include<cstdio>
#include<cstring>
#include<stdlib.h>
double num[1005];
int num_1[1005];
int main()
{
memset(num, 0, sizeof(num)/8);
memset(num, 0, sizeof(num_1)/4);
int N = 2;
while(N--)
{
int n;
scanf("%d ",&n);
for(int i = 0;i < n ; i++)
{
int x;
double y;
scanf("%d %lf",&x,&y);
num[x] += y;
}
}
int j = 0;
for(int i = 1005;i >= 0;i--)
{
if(num[i] != 0)
j++;
}
printf("%d",j);
for(int i = 1005;i >= 0;i--)
{
if(num[i] != 0)
printf(" %d %.1lf",i,num[i]);
}
return 0;
}
边栏推荐
- 依赖注入(Dependency Injection)框架是如何实现的
- ICML 2022 | Out-of-Distribution检测与深最近的邻居
- People | How did I grow quickly from programmer to architect?
- PTA 矩阵运算
- 从位图到布隆过滤器
- ∘(空心的点乘)的数学含义
- ACM最长不下降子序列问题
- OC-NSTimer
- 程序员的专属浪漫——用3D Engine 5分钟实现烟花绽放效果
- Use gdb to debug multi-process programs, debug parent and child processes at the same time
猜你喜欢
x86异常处理与中断机制(2)中断向量表
激光条纹中心提取——灰度重心法
Netscope: Online visualization tool for neural network structures
x86 Exception Handling and Interrupt Mechanism (3) Interrupt Handling Process
MATLAB中如何把cftool拟合的函数输出到命令行(解决如何导出拟合后的曲线数据)
vite的原理,手写vite
End-to-End Object Detection with Fully Convolutional Network学习笔记
全网最简单解决OneNote中英字体不统一
性能测试(04)-表达式和业务关联-JDBC关联
数论知识点
随机推荐
CentOS6.5 32bit安装Oracle-11gR2步骤说明
【C language】typedef的使用:结构体、基本数据类型、数组
matlab fcnchk 函数用法
百钱买鸡(一)
ThreadLocal及其内存泄露分析
PTA习题 阶梯电价(C)
grpc系列-初探grpc 路由注册和转发实现
c语言函数的递归调用(汉诺塔问题,楼梯递归问题等)
使用gdb调试多进程程序、同时调试父进程和子进程
C语言中信号函数(signal)的使用
Open3D point cloud average point spacing evaluation
双向链表的各种操作
es6递归函数
杂记(6)
FreeRTOS任务创建源码分析
The use of gdb tui
ACM最长不下降子序列问题
最长回文子串
数论知识点
性能测试(04)-表达式和业务关联-JDBC关联