1002. A+B for Polynomials (25)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了1002. A+B for Polynomials (25)相关的知识,希望对你有一定的参考价值。

题目: 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)的主要内容,如果未能解决你的问题,请参考以下文章

PTA-1002——A+B for Polynomials

PAT1002:A+B for Polynomials

PAT1002 A+B for Polynomials

PAT A1002 A+B for Polynomials

1002 A+B for Polynomials

1002. A+B for Polynomials (25)