当前位置:网站首页>Pat grade a 1048 find coins
Pat grade a 1048 find coins
2022-07-26 16:12:00 【IX. is it a non random title】
Self written content :
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
using namespace std;
int main(void){
int i, j, k, m, n, h, mm, nn;
cin>>m>>n;
vector<int> v;
for(i=0; i<m; i++){
cin>>h;
v.push_back(h);
}
sort(v.begin(), v.end());
int minmin = 9999999;
for(i=0; i<m; i++){
if(v[i] >= n) break;
for(j=i+1; j<m; j++){
mm = v[i] + v[j];
if(mm==n) {
minmin = v[i];
cout<<v[i]<<" "<<v[j];
return 0;
}
}
}
cout<<"No Solution";
return 0;
}Refer to others :
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
using namespace std;
int main(void){
int i, j, k, m, n, h, mm, nn;
cin>>m>>n;
int a[10001];
memset((void *)a, 0, sizeof(int) * (10001));
for(i=0; i<m; i++){
cin>>h;
a[h]++;
}
for(i = 0; i < 10001; i++){
if(a[i]){
a[i]--;
if(n > i && a[n-i]){
cout<<i<<" "<<n-i;
return 0;
}
a[i]++;
}
}
cout<<"No Solution";
return 0;
}
边栏推荐
- First knowledge of OpenGL (4) link shader
- [physical simulation] ultra simple shape matching simulates rigid body motion
- FTP protocol
- 共议公共数据开放,“数牍方案”亮相数字中国建设峰会
- Build resume editor based on Nocode
- Operating system migration practice: deploying MySQL database on openeuler
- ZABBIX 6.2.0 deployment
- Finally, someone explained the red blue confrontation clearly
- 2021年软件测试工具趋势
- 一款可视化浏览器历史的 Firefox/Chrome 插件
猜你喜欢

基于SSM开发实现校园疫情防控管理系统

Google Earth engine - merra-2 m2t1nxaer: aerosol daily data set from 1980 to 2022

Operating system migration practice: deploying MySQL database on openeuler
![API version control [eolink translation]](/img/3a/8a78e57a2474f33d011d91631fde74.jpg)
API version control [eolink translation]

PAT甲级 1047 Student List for Course

Test cases should never be used casually, recording the thinking caused by the exception of a test case
![[dsctf2022] PWN supplementary question record](/img/fa/ea26fc0861224df4c391942075eaaf.png)
[dsctf2022] PWN supplementary question record

parker泵PV140R1K1T1PMMC

基于SSM实现个性化健康饮食推荐系统

German EMG e-anji thruster ed301/6 HS
随机推荐
基于SSM开发实现校园疫情防控管理系统
TKE集群节点max-pod是如何配置的
js 对数组操作的 API 总结
Vs2019debug mode too laggy can't enter the breakpoint
2022 what is your sense of security? Volvo asked in the middle of the year
German EMG e-anji thruster ed301/6 HS
Implementation of SAP ABAP daemon
First knowledge of OpenGL (2) compilation shaders
First knowledge of OpenGL (3) fragment shader
Understanding weight sharing in convolutional neural networks
PAT甲级1048 Find Coins
Operating system migration practice: deploying MySQL database on openeuler
共议公共数据开放,“数牍方案”亮相数字中国建设峰会
基于sisotool极点配置PI参数及基于Plecs的三相电压源逆变器仿真
八叉树建立地图并实现路径规划导航
[physical simulation] ultra simple shape matching simulates rigid body motion
《硅谷之谜》读后感
【物理模拟】超简单的shape matching模拟刚体运动
tensorboard多个events文件显示紊乱的解决办法
bucher齿轮泵QX81-400R301