首页 > 其他 > 详细

1002 A+B for Polynomials (25 分)(简单模拟,保留一位小数)

时间:2019-10-23 00:34:42      阅读:122      评论:0      收藏:0      [点我收藏+]

题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805526272000000

注意:保留一位小数

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
using namespace std;
const int maxn = 0x3f3f3f3f;
typedef long long ll;
int main() {
int k;
double a[1005];
memset(a,0,sizeof(a));
cin >> k;
int x;
double y;
for(int i = 0; i < k; i++) {
cin >> x >> y;
a[x] += y;
}
cin >> k;
for(int i = 0; i <k; i++) {
cin >> x >> y;
a[x] += y;
}
k = 0;
for(int i = 1000; i >= 0; i--) {
if(a[i] != 0) k++;
}
cout << k;
for(int i = 1000; i >= 0; i--) {
if(a[i] != 0) printf(" %d %.1lf",i,a[i]);
}
return 0;
}

1002 A+B for Polynomials (25 分)(简单模拟,保留一位小数)

原文:https://www.cnblogs.com/LLLAIH/p/11723535.html

(1)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!