当前位置:网站首页>PAT甲级1048 Find Coins
PAT甲级1048 Find Coins
2022-07-26 15:55:00 【九是否非随机的称呼】
自己写的内容:
#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;
}参考其他人写的:
#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;
}
边栏推荐
- 换把人体工学椅,缓解久坐写代码的老腰吧~
- Some cutting-edge research work sharing of SAP ABAP NetWeaver containerization
- ROS problems and Solutions - relying on package installation and unable to correct errors
- Robot hand eye calibration ax=xb (eye to hand and eye in hand) and plane nine point calibration
- Refuse noise, the entry journey of earphone Xiaobai
- 2022 what is your sense of security? Volvo asked in the middle of the year
- DELTA控制器RMC200
- FTP协议
- Paper: all models are wrong, but many are useful: all models are wrong, but many are useful: understand the importance of variables by studying a whole class of prediction models at the same time
- 辨析 Ruby 中的 Method 与 Proc
猜你喜欢

Using information entropy to construct decision tree

单例模式

小哥自创AI防拖延系统,一玩手机就被“闪瞎” | Reddit高热
FTP protocol

Parker pump pv140r1k1t1pmmc

技术风向标 | 云原生技术架构成熟度模型解读
![[expdp export data] expdp exports a table with 23 rows of records and no lob field. It takes 48 minutes. Please help us have a look](/img/ee/7bec8211dddc90e52c2bc0f56c8dd4.png)
[expdp export data] expdp exports a table with 23 rows of records and no lob field. It takes 48 minutes. Please help us have a look

A comprehensive review of image enhancement technology in deep learning

Tutorial (7.0) 05. Issue forticlient * forticlient EMS * Fortinet network security expert NSE 5 through forticlient EMS

基于SSM实现个性化健康饮食推荐系统
随机推荐
Daily1:SVM
DELTA控制器RMC200
Google Earth engine - merra-2 m2t1nxaer: aerosol daily data set from 1980 to 2022
操作系统迁移实战之在openEuler上部署MySQL数据库
A comprehensive review of image enhancement technology in deep learning
【物理模拟】最简单的shape matching的原理与实践
Google Earth Engine——MERRA-2 M2T1NXAER:1980-2022年气溶胶逐日数据集
测试用例千万不能随便,记录由一个测试用例异常引起的思考
阿里云DMS MySQL云数据库建表报错,求解!!
[expdp export data] expdp exports a table with 23 rows of records and no lob field. It takes 48 minutes. Please help us have a look
TI C6000 TMS320C6678 DSP+ Zynq-7045的ZYNQ PS + PL异构多核案例开发手册(1)
朋友圈如何测试(思维导图)
Refuse noise, the entry journey of earphone Xiaobai
Promise, async await and the solution of cross domain problems -- the principle of proxy server
Parker pump pv140r1k1t1pmmc
想让照片中的云飘起来?视频编辑服务一键动效3步就能实现
Vs2019debug mode too laggy can't enter the breakpoint
tensorboard多个events文件显示紊乱的解决办法
Clojure 运行原理之编译器剖析
一文搞懂│XSS攻击、SQL注入、CSRF攻击、DDOS攻击、DNS劫持
https://github.com/ZouJiu1/PAT