标签:
题目: 1002. A+B for Polynomials (25)
#include<stdio.h> #define N 1000 int main() { double poly[N+1]={0}; int n,m,i; int exp; double coef; scanf("%d",&n); m=n; for(i=0;i<n;i++) { scanf(" %d %lf",&exp,&coef); poly[exp]=coef; } scanf("%d",&n); m+=n; for(i=0;i<n;i++) { scanf(" %d %lf",&exp,&coef); if(poly[exp])m--; poly[exp]+=coef; if(poly[exp]==0)m--; } printf("%d",m); for(i=N;i>=0;i--) { if(poly[i])printf(" %d %.1lf",i,poly[i]); } }
1002. A+B for Polynomials (25)
标签:
原文地址:http://www.cnblogs.com/xLester/p/5902147.html