A1048
给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的更多相关文章
- A1048. Find Coins
Eva loves to collect coins from all over the universe, including some other planets like Mars. One d ...
- A1048 Find Coins (25 分)
一.技术总结 首先初看题目有点没读懂,题目大致意思是小明有很多个硬币不同面值的,但是现在他要到商家这里换新的面值, 且商家有一个规定,一个新的硬币必须要你两个硬币面值相加等于的来换,这一有第一个问题产 ...
- PAT甲级——A1048 Find Coins
Eva loves to collect coins from all over the universe, including some other planets like Mars. One d ...
- B1029/A1048 旧键盘损坏了,在输入一段文字时坏了的键不可以正常使用,现给出应输入的一段文字,和实际输出的文字,找出坏掉的键。
#include<cstdio> #include<cstring> const int maxn = 1000; bool HashTable[maxn] = { false ...
- 设备管理 USB ID
发现个USB ID站点,对于做设备管理识别的小伙伴特别实用 http://www.linux-usb.org/usb.ids 附录: # # List of USB ID's # # Maintain ...
- 1048 Find Coins (25 分)
1048 Find Coins (25 分) Eva loves to collect coins from all over the universe, including some other p ...
- PAT_A1048#Find Coins
Source: PAT A1048 Find Coins (25 分) Description: Eva loves to collect coins from all over the univer ...
- PAT甲级题解分类byZlc
专题一 字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d& ...
随机推荐
- VC listBox控件的方法
获取listBox里所有行数 GetCount(); 设置某行的选中状态 SetSel(index,true);第一个参数是行号,第二个参数是否选中
- codeforces 809C Find a car
codeforces 809C Find a car 题意 有个\(1e9*1e9\)的矩阵,行 \(x\) 从上到下递增,列 \(y\) 从左到右递增.每个格子有一个正值.\((x, y)\) 的值 ...
- 小白学CMD下运行MySQL
将mysql目录下bin目录中的mysql.exe放到C:\WINDOWS下,可以执行以下命令 连接:mysql -h主机地址 -u用户名 -p用户密码 (注:u与root可以不用加空格,其它也一样) ...
- css属性之flex属性
flex属性 规定了弹性元素如何伸长或缩短以适应flex容器中的可用空间.是一个简写属性,可以同时设置flex-grow, flex-shrink, flex-basis三个子属性. /* Basic ...
- Angular不同版本对应的Bootstrap组件
AngularJS 1.x版本对应的 bootstrap组件库是ui-bootstrap; http://www.cnblogs.com/pilixiami/p/5597634.html Angula ...
- ajax获取json形式得题目和答案 实现答题功能
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- HTML5旋转立方体
http://42.121.104.41/templets/default/test1.htm 须要源代码的留言邮箱哈~
- Odoo模块添加logo
模块的static目录是专门用于存放静态文件内容如:图片.css等的.其中,description目录是存放关于模块的一些描述性的文件的,其中,模块的图标也放在下面,以icon命名.
- 6、RabbitMQ-路由模式
Exchange(交换机 转换器) Exchange分发消息时根据类型的不同分发策略有区别, 目前共四种类型:direct.fanout.topic.headers . 一方面是接受生产者的消息, ...
- 《metasploit渗透测试魔鬼训练营》学习笔记第七章--社会工程学
五.社工工程学 5.1社会工程系框架 5.1.1信息搜集 maltego是一个高度自动化的信息搜集工具,集成在BT5中,如果国内网络环境使用时 ...