/*
  1. 系数为0不输出
  2. 貌似runtime异常也显示答案不正确

    */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer; public class Main {
@SuppressWarnings("unchecked")
public static void main(String[] args) throws IOException {
StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
in.nextToken();
int n = (int) in.nval;
int[] N = new int[n];
double[] a = new double[n];
for (int i = 0; i < n; i++) {
in.nextToken();
N[i] = (int) in.nval;
in.nextToken();
a[i] = in.nval;
}
in.nextToken();
int m = (int) in.nval;
int[] M = new int[m];
double[] b = new double[m];
for (int i = 0; i < m; i++) {
in.nextToken();
M[i] = (int) in.nval;
in.nextToken();
b[i] = in.nval;
}
double[] map = new double[N[0] + M[0]+1];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
map[N[i] + M[j]] += a[i] * b[j];
}
}
int k = 0;
for (int i = N[0] + M[0]; i >= N[n - 1] + M[m - 1]; i--) {
if (Math.abs(map[i]) > 0.0001) {
k++;
}
}
System.out.print(k);
for (int i = N[0] + M[0]; i >= N[n - 1] + M[m - 1]; i--) {
if (Math.abs(map[i]) > 0.0001) {
System.out.print(String.format(" %d %.1f", i, map[i]));
}
}
System.out.println();
}
}

PAT 甲级【1009 Product of Polynomials】的更多相关文章

  1. PAT 甲级 1009 Product of Polynomials (25)(25 分)(坑比较多,a可能很大,a也有可能是负数,回头再看看)

    1009 Product of Polynomials (25)(25 分) This time, you are supposed to find A*B where A and B are two ...

  2. pat 甲级 1009. Product of Polynomials (25)

    1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...

  3. PAT甲级——1009 Product of Polynomials

    PATA1009 Product of Polynomials Output Specification: For each test case you should output the produ ...

  4. PAT甲 1009. Product of Polynomials (25) 2016-09-09 23:02 96人阅读 评论(0) 收藏

    1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...

  5. 【PAT】1009. Product of Polynomials (25)

    题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1009 分析:简单题.相乘时指数相加,系数相乘即可,输出时按指数从高到低的顺序.注意点:多项式相 ...

  6. PAT Advanced 1009 Product of Polynomials (25 分)(vector删除元素用的是erase)

    This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: Each ...

  7. PAT甲级——A1009 Product of Polynomials

    This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: Each ...

  8. PAT——甲级1009:Product of Polynomials;乙级1041:考试座位号;乙级1004:成绩排名

    题目 1009 Product of Polynomials (25 point(s)) This time, you are supposed to find A×B where A and B a ...

  9. PAT 1009 Product of Polynomials

    1009 Product of Polynomials (25 分)   This time, you are supposed to find A×B where A and B are two p ...

  10. PTA (Advanced Level) 1009 Product of Polynomials

    1009 Product of Polynomials This time, you are supposed to find A×B where A and B are two polynomial ...

随机推荐

  1. 20.4 延迟加载DLL--《Windows核心编程》

    延迟加载的 DLL 是个隐含链接的 DLL,它实际上要等到你的代码试图引用 DLL 中包含的一个符号时才进行加载. DLL延迟加载技术的原理,就是从导入表中去掉某dll这一项,等到正式调用DLL的时候 ...

  2. Linux常用的20个命令(下)

    无论你是后端程序员还是前端程序员,都避免不了和Linux打交道.上篇介绍了Linux常用的20个命令其中的10个,本文继续介绍剩下的10个命令. 11.man 命令 manual的缩写,即使用手册的意 ...

  3. 适用于Spring Boot Jar的启停部署脚本

    shell脚本参数 使用-z或-n对一个变量判空时, 若直接使用[ -n ARG ]这种形式,当{ARG}中有空格将会报错, line 27: [: sd: binary operator expec ...

  4. SpringCloud OpenFeign服务接口调用

    介绍 OpenFeign是一种声明式.模板化的HTTP客户端.在Spring Cloud中使用OpenFeign,可以做到使用HTTP请求访问远程服务,就像调用本地方法一样的,开发者完全感知不到这是在 ...

  5. Oracle 表压缩(Table Compression)技术介绍

    Oracle 表压缩(Table Compression)介绍 1.官方文档说法: As your database grows in size, consider using table compr ...

  6. 如何用Apipost校验响应结果

    数据校验的意义 我们可以通过 json-schema 预先定义接口的数据返回格式,当接口完成后,我们可以通过匹配 实际响应结果 和 预先定义的接口格式 ,来发现接口问题.如下图: 数据校验的设置 我们 ...

  7. 学习go语言编程之流程控制

    Golang支持如下4种流程控制语句: 条件语句:if,else和else if 选择语句:switch,case和select 循环语句:for,range 跳转语句:goto 条件语句 示例代码: ...

  8. 二: sql模式(sql_mode)

    # sql_mode 1 介绍 sql_mode 会影响 MySQL支持的SQL语法以及它执行的数据验证检查.通过设置sql_mode,可以完成不同严格程度 的数据校验,有效地保障数据准确性. MyS ...

  9. SpringCloud Eureka基本使用

    1. 简介 Eureka是Netflix开发的服务发现框架,并被Spring cloud 收录 并封装成为其服务治理的模块实现 Eureka采用了CS的架构设计,分为 Server端 和 Client ...

  10. Python中那些简单又好用的特性和用法

    Python作为我的主力语言帮助我开发了许多DevOps运维自动化系统,这篇文章总结几个我在编写Python代码过程中用到的几个简单又好用的特性和用法,这些特性和用法可以帮助我们更高效地编写Pytho ...