入门模拟A1009 Product of Polynomials(25)

2019-12-21

14:29:21

#include <bits/stdc++.h>
#include<math.h>
using namespace std;
const int MAX_LEN = 10001;
int main(){
    /*//A多项式,B多项式:
    vector<int,double> A(MAX_LEN);
    //初始化
    for(int i=0;i<MAX_LEN;++i){
        A[i]=0;
    }
    hash_map<int,double> B(MAX_LEN);
    for(int i=0;i<MAX_lEN;++i){
        B[i]=0;
    }
    //
    int count = 0;
    cin>>count;
    for(int i=0;i<count;++i){
        int fir = 0;
        double sec = 0;
        cin>>fir;
        cin>>sec;
        A[fir] = sec;
    }
    int count2=0;
    cin>>count2;
    for(int i =0;i<count2;++i){
        int fir = 0;
        double sec = 0;
        cin>>fir;
        cin>>sec;
        B[fir] = sec;
    }
    //
    for(int i=0;i<MAX_LEN;++i){
        if(A[i]!=0){
            B[i] += A[i];
        }
    }
    int count1 = 0;
    for(int i=0;i<MAX_LEN;++i){
        if(B[i]!=0){
            count1++;
        }
    }
    cout<<count1;
    for(int i=MAX_LEN-1;i>=0;--i){
        if(B[i]!=0){
            cout<<i<<B[i]<<" ";
        }
    }*/
    //A,B:
    double A[MAX_LEN]={0};
    double B[MAX_LEN]={0};
    int count = 0;
    cin>>count;
    for(int i=0;i<count;++i){
        int fir = 0;
        double sec = 0;
        cin>>fir;
        cin>>sec;
        A[fir] =  sec;
    }
    int count2=0;
    cin>>count2;
    for(int i =0;i<count2;++i){
        int fir = 0;
        double sec = 0;
        cin>>fir;
        cin>>sec;
        B[fir]  = sec;
    }
    for(int i=0;i<MAX_LEN;++i){
        if(A[i]!=0){
            B[i] += A[i];
        }
    }
    int count1 = 0;
    for(int i=0;i<MAX_LEN;++i){
        if(B[i]!=0){
            count1++;
        }
    }
    cout<<count1;
    for(int i=MAX_LEN-1;i>=0;--i){
        if(B[i]!=0){
            cout<<" "<<i<<" "<<B[i];
        }
    }
    system("pause");
    return 0;
} 

原文地址:https://www.cnblogs.com/JasonPeng1/p/12076846.html

时间: 2024-11-08 23:09:44

入门模拟A1009 Product of Polynomials(25)的相关文章

PAT 1009. Product of Polynomials (25)

1009. Product of Polynomials (25) This time, you are supposed to find A*B where A and B are two polynomials. Input Specification: Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomi

pat1009. Product of Polynomials (25)

1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue This time, you are supposed to find A*B where A and B are two polynomials. Input Specification: Each input file contains one test case. Each case oc

1009. Product of Polynomials (25)——PAT (Advanced Level) Practise

题目信息: 1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue This time, you are supposed to find A*B where A and B are two polynomials. Input Specification: Each input file contains one test case. Each c

1009 Product of Polynomials (25)(25 分)

1009 Product of Polynomials (25)(25 分) This time, you are supposed to find A*B where A and B are two polynomials. Input Specification: Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a pol

1009 Product of Polynomials (25分) 多项式乘法

1009 Product of Polynomials (25分) This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomi

[PTA] PAT(A) 1009 Product of Polynomials (25 分)

目录 Problem Description Input Output Sample Sample Input Sample Output Solution Analysis Code Result Problem portal:1009 Product of Polynomials Description Input Output Sample Sample Input Sample Output Solution Analysis Code #include <bits/stdc++.h>

PAT A1009 Product of Polynomials (25 分)

This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial: K N?1?? a?N?1???? N?2?? a?N?2?

PAT甲级——A1009 Product of Polynomials

This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial: K N?1?? a?N?1???? N?2?? a?N?2?

1009 Product of Polynomials (25)(25 point(s))

problem This time, you are supposed to find A*B where A and B are two polynomials. Input Specification: Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial: K N1 a~N1~ N2 a~N2~ ..