给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. SCOM中的通配符

    通配符模式匹配按从左到右的方式完成,一次匹配一个字符或基本通配符模式.模式和传入字符串必须完全匹配,因此,举例来说,模式“abc”与字符串“abcd”不匹配.复合模式包含由 (&) 号或波形符 ...

  2. switch与java

    switch结构可以更好的解决等值判断问题switch 选择结构的语法:switch (表达式){case 常量 1://代码块1:break;case 常量 2://代码块2:break;..... ...

  3. gitlab自动备份恢复与卸载

    一.gitlab数据备份gitlab-rake gitlab:backup:create命令会在/var/opt/gitlab/backups目录下创建一个名称类似为1393513186_gitlab ...

  4. MP4个人制作

  5. winform中webBrowser模拟网页操作中遇到的问题

    我们通过网页上传一些特殊数据的时候,由于必填项众多,数量量大的时候,会发现工作相当繁琐,前段时间做了一个winform内嵌webBrowser模拟网页上传文档的小工具,发现了许多问题,总结一下: 先说 ...

  6. Chapter 2 Secondary Sorting:Detailed Example

    2.1 Introduction MapReduce framework sorts input to reducers by key, but values of reducers are arbi ...

  7. php & laravel 相关收集

    http://www.oschina.net/news/49207/best-php-debugging-tools 调试相关工具 https://github.com/barryvdh/larave ...

  8. mac 学习笔记

    1.关于launchctl http://zhengwei.name/2011/11/lanunchctl-notes/ 2.php-fpm 默认配置 php-fpm.conf :/etc/php-f ...

  9. linux环境下 C++性能测试工具 gprof + kprof + gprof2dot

    1.gprof 很有名了,google下很多教程 g++ -pg -g  -o test test.cc ./test   //会生成gmon.out gprof ./test > prof.l ...

  10. 【转】多线程Core Data

    原文地址:http://www.cocoanetics.com/2012/07/multi-context-coredata/ Multi-Context CoreData When you star ...