PAT 甲级 A1002 (2019/01/30)

 1 #include<cstdio>
 2 const int MAXN = 1001;
 3 double sum[MAXN];
 4 int main(){
 5     int exp, n, count = 0;    //次数
 6     double coe;                      //系数
 7     scanf("%d",&n);
 8     for(int i = 0; i < n; i++){
 9         scanf("%d %lf", &exp, &coe);  //下标存次数,value存系数
10         sum[exp] += coe;
11     }
12     scanf("%d",&n);
13     for(int i = 0; i < n; i++){
14         scanf("%d %lf", &exp, &coe); //下标存次数,value存系数
15         sum[exp] += coe;
16     }
17     for(int i = 0; i < MAXN; i++){
18         if(sum[i] != 0)
19             count++;
20     }
21     printf("%d",count);
22     for(int i = MAXN; i >= 0; i--)
23         if(sum[i] != 0) printf(" %d %.1f", i, sum[i]);
24     return 0;
25 } 

原文地址:https://www.cnblogs.com/zjsaipplp/p/10415760.html

时间: 2024-08-30 05:29:13

PAT 甲级 A1002 (2019/01/30)的相关文章

【谜客帝国】第146届千江雪主擂谜会(2019.01.30)

 [谜客帝国]第146届千江雪主擂谜会(2019.01.30) 主持:瓷   计分:雪宝 1. 几回驻马观潮起(对人评价语)没主见 2. “他年我若为青帝”(商品连价位2+2)花生一块 [注:面出黄巢<题菊花>,启下句 “报与桃花一处开”] 3. 看我横戈行天下(东北方言)大手 4. 寒梅凋谢扑满衣(对<红楼梦>人物态度)冷落花袭人 5. 挥手拢琴动凡心(诛仙小说人物)玲珑 6. “纵使相逢应不识”(3字猜不出谜原因)面太生 [面出苏轼<江城子 记梦>] 7. 松间小月

PAT甲级——A1155 HeapPaths【30】

In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (in a max heap) or less than or equal to (in a min h

PAT甲级【2019年3月考题】——A1158 TelefraudDetection【25】

Telefraud(电信诈骗) remains a common and persistent problem in our society. In some cases, unsuspecting victims lose their entire life savings. To stop this crime, you are supposed to write a program to detect those suspects from a huge amount of phone c

PAT 甲级 1049 Counting Ones (30 分)(找规律,较难,想到了一点但没有深入考虑嫌麻烦)***

1049 Counting Ones (30 分) The task is simple: given any positive integer N, you are supposed to count the total number of 1's in the decimal form of the integers from 1 to N. For example, given N being 12, there are five 1's in 1, 10, 11, and 12. Inp

PAT甲级——1147 Heaps【30】

In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (in a max heap) or less than or equal to (in a min h

PAT甲级1005 Spell It Right

题目:PAT甲级 1005 题解:水题.看到题目的第一时间就在想一位一位的mod,最后一加一转换就完事了.结果看到了N最大为10的100的次方,吓得我赶紧放弃这个想法... 发现碰到这种情况用字符串十分好用,这道题应该考察的就是这一点.大致思路就是把数字的每一位放到字符串中,然后通过ASCII码得到每一位的相加结果num,然后把num一位一位的放到stack中,使用stack是因为它先进先出的特性,最后输出就行了. 代码: 1 #include<cstdio> 2 #include<qu

【谜客帝国】第145届芭比娃娃主擂谜会(2019.01.15)

[谜客帝国]第145届芭比娃娃主擂谜会(2019.01.15) 主持:瓷   计分:默沫 1. 同心十八载,白首居河东(2字2019亚洲杯中国球员)石柯 2. 王朗气极坠地死(3字方位字)骂下马 [注:典据<三国演义>93回,“王朗听罢,气满胸膛,大叫一声,撞死于马下.”] 3. 城头长弓搭白羽(2字宋词人)张翥 4. 重门折屐未曾进(成语)格格不入 [注:重门.折屐,皆为谜格.] 5.“石城古岸头”(2字国家森林公园)圭山 6. 凯撒大帝显露出愤怒(4字<诗经>名句)七月流火 [

PAT 1076. Forwards on Weibo (30)

题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1076 此题考查图的遍历操作: 本来我个人觉得可以用dfs的,但是不知何故,有两个case没有过,贴出代码,望指出错误之处: #include <cstdio> #include <map> #include <vector> #include <memory.h> using namespace std; const int NUM=1001; bool

C#加密算法汇总(转载)http://www.cnblogs.com/zengxiangzhan/archive/2010/01/30/1659687.html

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 方法一:     //须添加对System.Web的引用     using System.Web.Security;          ...          /// <summary>     /// SHA1加密字符串     /// </summary>     /// <param name="source"