当前位置:网站首页>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;
}
边栏推荐
- HaWe screw cartridge check valve RK4
- DELTA控制器RMC200
- 使用 ClojureScript 开发浏览器插件的过程与收获
- 开发日常小结(11):文件上传功能改进:中文字符检测与文本内容处理
- How to use job plug-in type to call a kettle job through ETL scheduling tool taskctl?
- German EMG e-anji thruster ed301/6 HS
- Coo format of adjacency matrix
- 技术风向标 | 云原生技术架构成熟度模型解读
- 测试用例千万不能随便,记录由一个测试用例异常引起的思考
- 十周岁生日快乐,Clojure
猜你喜欢

2022你的安全感是什么?沃尔沃年中问道

如何通过ETL调度工具 TASKCTL 使用作业插件类型调用 kettle作业?

My brother created his own AI anti procrastination system, and he was "blinded" when playing with his mobile phone | reddit was hot

Change an ergonomic chair to relieve the old waist of sitting and writing code~

Digital warehouse: iqiyi digital warehouse platform construction practice
![[tool sharing] automatic generation of file directory structure tool mddir](/img/bc/1071c0dfb20d16f5fdde641092c1af.png)
[tool sharing] automatic generation of file directory structure tool mddir

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

Kalibr calibration realsensed435i -- multi camera calibration

Bucher gear pump qx81-400r301

API 版本控制【 Eolink 翻译】
随机推荐
深度学习中图像增强技术的综合综述
Encryption model
Pandora IOT development board learning (RT thread) - Experiment 17 esp8266 experiment (learning notes)
Tutorial (7.0) 05. Issue forticlient * forticlient EMS * Fortinet network security expert NSE 5 through forticlient EMS
【ARM学习(9) arm 编译器了解学习(armcc/armclang)】
Specific practice cases of "card note taking method" in Siyuan
API version control [eolink translation]
OSPF comprehensive experiment
基于NoCode构建简历编辑器
Implementation of SAP ABAP daemon
中金财富证券安全吗 开户要多久
小哥自创AI防拖延系统,一玩手机就被“闪瞎” | Reddit高热
A coal mine in Yangquan, Shanxi Province, suffered a safety accident that killed one person and was ordered to stop production for rectification
PS + PL heterogeneous multicore case development manual for Ti C6000 tms320c6678 DSP + zynq-7045 (2)
【DSCTF2022】pwn补题记录
Octree establishes map and realizes path planning and navigation
“卡片笔记法”在思源的具体实践案例
TI C6000 TMS320C6678 DSP+ Zynq-7045的PS + PL异构多核案例开发手册(4)
TI C6000 TMS320C6678 DSP+ Zynq-7045的PS + PL异构多核案例开发手册(2)
Jointly discuss the opening of public data, and the "digital document scheme" appeared at the digital China Construction Summit
https://github.com/ZouJiu1/PAT