入门模拟A1009 Product of Polynomials(25)

2019-12-23

14:54:40

入门模拟A1009 Product of Polynomials(25)

 

 

#include <bits/stdc++.h>
#include<math.h>
using namespace std;
const int MAX_LEN = 2004;
int main(){
    double temp1[MAX_LEN]={0};
    double temp2[MAX_LEN]={0};
    int tem1;
    cin>>tem1;
    for(int i =0;i<tem1;++i){
        int fir;
        double sec;
        cin>>fir;
        cin>>sec;
        temp1[fir] = sec;
    }
    int tem2;
    scanf("%d",&tem2);
    for(int i=0;i<tem2;++i){
        int fir = 0;
        double sec = 0;
        cin>>fir;
        cin>>sec;
        temp2[fir] = sec;
    }
    double temp3[MAX_LEN] = {0};
    int count = 0;
    for(int i =MAX_LEN;i>=0;--i){
        for(int j=MAX_LEN;j>=0;--j){
            if(temp1[i]==0){
                break;
            }
            else{
                if(temp2[j]!=0){
                    //count++;
                    temp3[j+i] += (temp1[i]*temp2[j]);
                }
            } 
        }
    }
    for(int i=MAX_LEN;i>=0;--i){
        if(temp3[i]!=0&&i!=MAX_LEN){
            count++;
        }
    }
    cout<<count;
    for(int i=MAX_LEN;i>=0;--i){
        if(temp3[i]!=0&&i!=MAX_LEN){
            printf(" %d %.1f",i,temp3[i]);
        }
    }
上一篇:coe_xfr_sql_profile.sql和coe_load_sql_profile.sql


下一篇:COE 2SH4