标签:mat names rate lease pre als col space clu
#include <math.h> #include <stdio.h> #include <iostream> using namespace std; int main() { int k1,k2,n,max_n=0,c=0; double an; double poly[1001]={0}; cin>>k1; for(int i=0;i<k1;i++) { cin>>n>>an; poly[n]=an; if(n>max_n) max_n=n; } cin>>k2; for(int i=0;i<k2;i++) { cin>>n>>an; poly[n]+=an; if(n>max_n) max_n=n; } for(int i=max_n;i>=0;i--) if(poly[i]!=0) c++; cout<<c; for(int i=max_n;i>=0;i--) if(poly[i]!=0) printf(" %d %.1f",i,poly[i]);//注意保留一位小数,否则有几个测试数据过不去(Please be accurate to 1 decimal place.) return 0; }
1002 A+B for Polynomials (25分)
标签:mat names rate lease pre als col space clu
原文地址:https://www.cnblogs.com/QRain/p/12275642.html