-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1009.cpp
50 lines (44 loc) · 864 Bytes
/
1009.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// 1009.cpp
// 算法
//
// Created by 王怡凡 on 2017/5/15.
// Copyright © 2017年 王怡凡. All rights reserved.
//
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 1100;
float ans[2001];
struct poly {
int ex;
float co;
}polis[maxn];
int main() {
int k1, k2, i,j,num=0;
poly p;
scanf("%d",&k1);
for(i=0;i<k1;i++) {
scanf("%d %f",&p.ex,&p.co);
polis[i] = p;
}
scanf("%d",&k2);
for(i=0;i<k2;i++) {
scanf("%d %f",&p.ex,&p.co);
for(j=0;j<k1;j++) {
ans[polis[j].ex+p.ex] += polis[j].co*p.co;
}
}
for(i=2000;i>=0;i--) {
if(ans[i]!=0.0) {
num++;
}
}
printf("%d",num);
for(i=2000;i>=0;i--) {
if(ans[i]!=0.0) {
printf(" %d %.1f",i,ans[i]);
}
}
return 0;
}