/*
  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. 阿里二面:SpringBoot可以同时处理多少个请求?当场懵了。。。。

    SpringBoot以其简洁高效的开发方式和强大的内嵌容器特性,为开发者提供了构建高性能后端服务的便利.然而,当面临高并发场景时,理解并合理配置Spring Boot应用以达到最佳的并发处理能力至关重 ...

  2. 使用C语言构建一个独立栈协程和共享栈协程的任务调度系统

    使用了标准库头文件 <setjmp.h>中的 setjmp 和 longjmp两个函数,构建了一个简单的查询式协作多任务系统,支持独立栈和共享栈两种任务. 其中涉及到获取和设置栈的地址操作 ...

  3. 下载安装JDK 和 IntelliJ IDEA 和 ActiveMq

    wget http://yun.diandaxia.com/other/jdk-8u92-linux-x64.rpm rpm -ivh jdk-8u92-linux-x64.rpm wget http ...

  4. IntPtr 来把指针转换为 Int

    由于想得到指针的值,这个时候,不能把指针强制转换为 integer 因为 integer 只适合32位的系统,64位的系统下,需要用 int64, 通过这个函数来转换,就可以屏蔽掉系统是32位 还是 ...

  5. Word-批量导出Word中的图片

    当我们需要把Word文件中的图片保存起来,你是如何导出Word图片呢?右键一张张保存图片吗?这效率太低了.如果文档中有大量的图片,这个方法会浪费很多时间. 下面给大家分享word如何批量导出图片的技巧 ...

  6. [Java]Map接口有关总结

    Map接口 1.HashMap和Hashtable的区别 线程安全方面.HashMap是非线程安全的,Hashtable是线程安全的.因为Hashtable内部方法基本都经过synchronized修 ...

  7. 编译pjsip源码

    操作系统 : Windows 10_x64 [版本 10.0.19042.685] pjsip版本 : 2.10 pjsip官网:https://www.pjsip.org/ 1. 下载pjsip源代 ...

  8. Blazor OIDC 单点登录授权实例5 - 独立SSR App (net8 webapp ) 端授权

    目录: OpenID 与 OAuth2 基础知识 Blazor wasm Google 登录 Blazor wasm Gitee 码云登录 Blazor OIDC 单点登录授权实例1-建立和配置IDS ...

  9. Slot 的含义

    Slot 解释 1)slot就是槽的意思,是一个资源单位,只有给task分配了一个slot之后,这个task才可以运行.slot分两种,map slot沪蓉reduce slot.另外,slot是一个 ...

  10. vmware之NAT模式配置

    ​ 题外话之前的题外话,本文迁移自别的社区,三年前大学实习时写下本文,过了几年再回过头来看,虽然讲得浅显,作为入门笔记也勉强合格. ---------------------------------- ...