当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
Cesium加载三维模型数据
matlab图像分割,从基因芯片荧光图像中提取阴性点(弱)和阳性点(强)
电磁场与电磁波-场论基础
全网最简单解决OneNote中英字体不统一
爱可可AI前沿推介(8.9)
1009 Product of Polynomials C语言多项式乘积(25分)
性能测试(04)-表达式和业务关联-JDBC关联
electron 应用开发优秀实践
Preparation for gold three silver four: how to successfully get an Ali offer (experience + interview questions + how to prepare)
b站up主:空狐公子 --矩阵求导(分母布局)课程笔记
随机推荐
x86 exception handling and interrupt mechanism (2) interrupt vector table
1006 Sign In and Sign Out (25分)
MATLAB中如何把cftool拟合的函数输出到命令行(解决如何导出拟合后的曲线数据)
CAN总线发送数据
在线编译matlab,亲测好用
二进制加法
为什么组合优先于继承
es6对象迭代器iterator
log4net使用指南(winform版,sqlserver记录)
Missing URI template variable ‘employeeNumber‘ for method parameter of type String
gdb 10.2的安装
1008 Elevator (20分)
golang runtime Caller、Callers、CallersFrames、FuncForPC、Stack作用
ICML 2022 | Out-of-Distribution检测与深最近的邻居
golang源代码阅读,sync系列-Pool
性能测试(04)-表达式和业务关联-JDBC关联
PAT1003
Installation of gdb 10.2
程序员的专属浪漫——用3D Engine 5分钟实现烟花绽放效果
Quartz分布式实现