pat1009
来源:互联网 发布:万网域名注册要多少钱 编辑:程序博客网 时间:2024/06/05 20:06
package AdvancedLevelPractice;import java.util.Iterator;import java.util.Map;import java.util.Scanner;import java.util.TreeMap;public class pat1009{public static void main(String[] args) {// TODO Auto-generated method stubScanner scanner = new Scanner(System.in);int n1 = scanner.nextInt();int[] exp = new int[n1];double[] coff = new double[n1];for(int i = 0; i < n1; i++){exp[i] = scanner.nextInt();coff[i] = scanner.nextDouble();}int n2 = scanner.nextInt();Map results = new TreeMap().descendingMap();int exp1, exp2;double coff1, coff2;int count = 0;for(int i = 0; i < n2; i++){exp1 = scanner.nextInt();coff1 = scanner.nextDouble();for(int j = 0; j < n1; j++){exp2 = exp1 + exp[j];coff2 = coff1 * coff[j];if(results.containsKey(exp2)){coff2 += Double.parseDouble(String.valueOf(results.get(exp2)));results.remove(exp2);count--;}if(!String.format("%.1f",coff2).contains("0.0")){count++;results.put(exp2, coff2);}}}Iterator iterator = results.keySet().iterator();System.out.print(count);while (iterator.hasNext()) {Object key = iterator.next();System.out.print(" "+ String.valueOf(key)+" "+String.format("%.1f", results.get(key)));}scanner.close();}}
0 0
- PAT1009
- pat1009
- pat1009
- PAT1009
- PAT1009
- PAT1009总结
- PAT1009. Product of Polynomials
- PAT1009. 说反话
- PAT1009. 说反话
- PAT1009. Product of Polynomials
- pat1009 Product of Polynomials
- PAT1009说反话 (20)
- PAT1009:说反话
- PAT1009-说反话 (20)
- pat1009:说反话
- PAT1009 说反话 (20)
- PAT1009. 说反话 (20)
- PAT1009. 说反话 (20)
- resolve problem II - Could not find or load main class
- 2015年,这15个IT岗位会涨薪?
- 应用框架的设计与实现.net平台--应用框架解析(框架开技术)
- mac下递归创建ctags报错: "illegal option -- R"
- Android的onCreateOptionsMenu()创建菜单Menu详解
- pat1009
- LeetCode Pascal's Triangle & Pascal's Triangle II
- Day21-日期时间对话框
- PhoneGap+Cordova+SenchaTouch-01-环境搭建
- 史上最详细MFC调用mapX5.02.26步骤(附地图测试GST文件)
- python操作Excel读写--使用xlrd
- 从JS到JQuery
- iOS8 在ipad 上面显示UIAlertController
- android动画详解