给n个正整数,再给一个m,如果n个数中存在a+b=m(a<=b),则输出a,b。

如果有两组以上,则输出a最小的一组。

 #include<cstdio>
#include<algorithm>
using namespace std;
const int N=;
int hashTable[N];
int main(){
int n,m,a;
scanf("%d %d",&n,&m);
for(int i=;i<n;i++){
scanf("%d",&a);
++hashTable[a];
}
for(int i=;i<N;i++){
if(hashTable[i]&&hashTable[m-i]){
if(i==m-i&&hashTable[i]<=){
continue;
}
printf("%d %d\n",i, m-i);
return ;
}
}
printf("No Solution\n");
return ;
}

A1048的更多相关文章

  1. A1048. Find Coins

    Eva loves to collect coins from all over the universe, including some other planets like Mars. One d ...

  2. A1048 Find Coins (25 分)

    一.技术总结 首先初看题目有点没读懂,题目大致意思是小明有很多个硬币不同面值的,但是现在他要到商家这里换新的面值, 且商家有一个规定,一个新的硬币必须要你两个硬币面值相加等于的来换,这一有第一个问题产 ...

  3. PAT甲级——A1048 Find Coins

    Eva loves to collect coins from all over the universe, including some other planets like Mars. One d ...

  4. B1029/A1048 旧键盘损坏了,在输入一段文字时坏了的键不可以正常使用,现给出应输入的一段文字,和实际输出的文字,找出坏掉的键。

    #include<cstdio> #include<cstring> const int maxn = 1000; bool HashTable[maxn] = { false ...

  5. 设备管理 USB ID

    发现个USB ID站点,对于做设备管理识别的小伙伴特别实用 http://www.linux-usb.org/usb.ids 附录: # # List of USB ID's # # Maintain ...

  6. 1048 Find Coins (25 分)

    1048 Find Coins (25 分) Eva loves to collect coins from all over the universe, including some other p ...

  7. PAT_A1048#Find Coins

    Source: PAT A1048 Find Coins (25 分) Description: Eva loves to collect coins from all over the univer ...

  8. PAT甲级题解分类byZlc

    专题一  字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d& ...

随机推荐

  1. ZT android -- 蓝牙 bluetooth (一) 入门

    android -- 蓝牙 bluetooth (一) 入门 分类: Android的原生应用分析 2013-05-19 21:44 4543人阅读 评论(37) 收藏 举报 bluetooth4.2 ...

  2. stderr: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

    错误提示: (1). stderr: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer direc ...

  3. FetchType与FetchMode的区别

    使用例: @OneToMany(mappedBy="item",cascade=CascadeType.ALL,fetch=FetchType.EAGER) @Fetch(valu ...

  4. 对Java中的异常的理解

    1.What is exception in Java? Java使用异常描述程序中可能出现的不正常情况.这个不正常可以是java认为的不正常,也可以是你主观上的出乎意料(自定义异常).总而言之,异常 ...

  5. How Flask Routing Works

    @How Flask Routing Works The entire idea of Flask (and the underlying Werkzeug library) is to map UR ...

  6. Xpath提取一个标签里的所有文本

    content = etree.HTML(text) h = content.xpath('//h1') h1 = h[0].xpath('string(.)').strip()

  7. Linux学习总结(十八)几个简单的文本处理工具cut sort tr split

    1 命令cut 用来截取某一个字段格式 : cut -d '分隔符' [-cf] n, n为数字,表示第几段-d:后面跟分隔符,分割符要加单引号-c:后面接的是第几个字符-f:后面接的是第几段那么意思 ...

  8. 【vue】饿了么项目-goods商品列表页开发

    1.flex 属性是 flex-grow.flex-shrink 和 flex-basis 属性的简写属性. flex-grow 一个数字,规定项目将相对于其他灵活的项目进行扩展的量. flex-sh ...

  9. Kali-linux使用Maltego收集信息

    Maltego是一个开源的漏洞评估工具,它主要用于论证一个网络内单点故障的复杂性和严重性.该工具能够聚集来自内部和外部资源的信息,并且提供一个清晰的漏洞分析界面.本节将使用Kali Linux操作系统 ...

  10. LayIM.AspNetCore Middleware 开发日记(四)主角登场(LayIM介绍)

    前言 在前几篇中已经初步介绍了开发AspNetCore中间件的一些基础知识,不过都没有很深入的去研究,后续还是需要去看看源码.本篇呢,终于有点开头的味道了,就是要介绍LayIM了,其实标题写的是主角, ...