# 1048. Find Coins (25)

50 ms

65536 kB

16000 B

Standard

CHEN, Yue

Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However, there was a special requirement of the payment: for each
bill, she could only use exactly two coins to pay the exact amount. Since she has as many as 105coins with her, she definitely needs your help. You are supposed to tell her, for any given amount of money, whether or not she
can find two coins to pay for it.

Input Specification:

Each input file contains one test case. For each case, the first line contains 2 positive numbers: N (<=105, the total number of coins) and M(<=103, the amount of money Eva has to pay). The second
line contains N face values of the coins, which are all positive numbers no more than 500. All the numbers in a line are separated by a space.

Output Specification:

For each test case, print in one line the two face values V1 and V2 (separated by a space) such that V1 + V2= M and V1 <=
V2. If such a solution is not unique, output the one with the smallest V1. If there is no solution, output "No Solution" instead.

Sample Input 1:

```8 15
1 2 8 7 2 4 11 15
```

Sample Output 1:

```4 11
```

Sample Input 2:

```7 14
1 8 7 2 4 11 15
```

Sample Output 2:

`No Solution`

```#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int cnt[5005];
int main()
{
int i,j,temp;
int n,m;
scanf("%d%d",&n,&m);
for (i=0;i<n;i++)
{
scanf("%d",&temp);
cnt[temp]++;
}
for (i=1;i<=m-i;i++)
{
cnt[i]--;cnt[m-i]--;
if (cnt[i]>=0&&cnt[m-i]>=0)
break;
}
if (i<=m-i)
printf("%d %d\n",i,m-i);
else
printf("No Solution\n");
return 0;
}
```

## PAT甲 1048. Find Coins (25) 2016-09-09 23:15 29人阅读 评论(0) 收藏的更多相关文章

1. PAT甲 1032. Sharing (25) 2016-09-09 23:13 27人阅读 评论(0) 收藏

1032. Sharing (25) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To store Engl ...

2. PAT甲 1029. Median (25) 2016-09-09 23:11 27人阅读 评论(0) 收藏

1029. Median (25) 时间限制 1000 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given an incr ...

3. PAT甲 1009. Product of Polynomials (25) 2016-09-09 23:02 96人阅读 评论(0) 收藏

1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...

4. PAT甲 1046. Shortest Distance (20) 2016-09-09 23:17 22人阅读 评论(0) 收藏

1046. Shortest Distance (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The ...

5. PAT甲 1041. Be Unique (20) 2016-09-09 23:14 33人阅读 评论(0) 收藏

1041. Be Unique (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Being uniqu ...

6. PAT甲 1011. World Cup Betting (20) 2016-09-09 23:06 18人阅读 评论(0) 收藏

1011. World Cup Betting (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Wit ...

7. PAT甲 1008. Elevator (20) 2016-09-09 23:00 22人阅读 评论(0) 收藏

1008. Elevator (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The highest ...

8. 本周博客--WinForm线程初步 2014-10-31 09:15 54人阅读 评论(0) 收藏

嗯,WinForm作为一个比较程序的微软的技术已经为我们服务了很久很久,在技术不断更新的今天WinForm虽显老态龙钟但是在客户端快速开发中,它的地位还是无可取代的 今天就来分享一下WinForm中的 ...

9. PIGS 分类： POJ 图论 2015-08-10 09:15 3人阅读 评论(0) 收藏

PIGS Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 18209 Accepted: 8277 Description Mir ...

## 随机推荐

2. JavaScript学习笔记-简单的计时钟表

<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> ...

3. 解决JS浮点数(小数)计算加减乘除的BUG

在JavaScript中输出下面这些数值(注意不能作为字符串输出):0.1000000000000000000000000001(28位小数).0.10000000000000000000000000 ...

4. activeMQ主要的几类集群部署方式

5. Unity3D 自动打包整个项目（以AssetBundle实现）

原地址:http://blog.csdn.net/huang7jiao/article/details/18370653 需求: 在移动开发中,手动控制资源的加载.释放和热更新,是很有必要的. 而Un ...

6. web项目学习之基于注解的Controller

1. 低版本Spring MVC 实现Controller 使用过低版本 Spring MVC 的读者都知道:当创建一个 Controller 时,我们需要直接或间接地实现 org.springfra ...

7. PHP开发APP接口

第1章 APP接口简介 - 课程简介 (:) - APP接口介绍 (:) - 客户端APP通信 (:) 最近学习 - 客户端APP通信格式区别 (:) - APP接口做的哪些事儿 (:) 第2章 封装 ...

8. [转] SDP协议

[转] SDP协议 http://blog.csdn.net/dxpqxb/article/details/18706471 1.SDP协议概述 SDP(Session Description Pro ...

9. centos7下安装pip以及mysql等软件

1.安装pip 安装失败了的提示: No package pip available.Error: Nothing to do 解决方法: 需要先安装扩展源EPEL. EPEL(http://fedo ...

10. 点击小图查看大图jQuery插件FancyBox魔幻灯箱

今日发现一个不错的JQuery插件FancyBox,也许早就有这个插件了,但是没名字,我就暂且叫他魔幻灯箱吧,采用Mac系统的样式.网传主要有以下功能:■弹出的窗口有很漂亮的阴影效果.■关联的对象(就 ...