1048. Find Coins (25)

news/2025/11/23 17:11:33/文章来源:https://www.cnblogs.com/WJQ2017/p/19260971

1048. Find Coins (25)

#include <iostream>
#include <algorithm>using namespace std;int c[510], num[100010];int main()
{int n, m;scanf("%d%d", &n, &m);int i;for(i = 1; i <= n; i++){scanf("%d", &num[i]);c[num[i]]++;}sort(num + 1, num + n + 1);int cha, flag = 0;for(i = 1; i <= n; i++){cha = m - num[i];c[num[i]]--;if(cha > 0 && cha <= 500 && c[cha] > 0){flag = 1;printf("%d %d\n", num[i], cha);break;}}if(flag == 0){printf("No Solution\n");}system("pause");return 0;
}

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/974055.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

1052. Linked List Sorting (25)

1052. Linked List Sorting (25)#include <iostream> #include <algorithm> #include <vector>using namespace std;struct node {int address, key, next; }nod[100000];int cmp(node n1, node n2)…

1051. Pop Sequence (25)

1051. Pop Sequence (25)#include <iostream> #include <stack>using namespace std;int main() {int m, n, k;scanf("%d%d%d", &m, &n, &k);int i, num[1010], j, index, flag, be…

卡塔兰long long

1.mod 我们用递推式用加法避免除和mod include <bits/stdc++.h> using namespace std; long long dp[105]; long long f(int x) { if(dp[x]!=-1) return dp[x]; dp[x]=0;//归0 for(int i=0;i<x;i++) { dp[x]=…

1038. Recover the Smallest Number (30)

1038. Recover the Smallest Number (30)#include <iostream> #include <string.h> #include <string> #include <algorithm> #include <vector>using namespace std;int cmp(string a,…

1037. Magic Coupon (25)

1037. Magic Coupon (25)#include <iostream> #include <vector> #include <algorithm>using namespace std;int main() {int nc;scanf("%d", &nc);int i;vector<long long> v[…

1040. Longest Symmetric String (25)

1040. Longest Symmetric String (25)#include <iostream> #include <string.h>using namespace std;int main() {char s[1010];gets(s);int len = strlen(s), i, count, res = 0, j, k;for(i = 0; i <…

1029. Median (25)

1029. Median (25)#include <iostream> #include <vector> #include <algorithm>using namespace std;int main() {int n;scanf("%d", &n);int i;long int num;vector<long int>…

1039. Course List for Student (25)

1039. Course List for Student (25)#include <iostream> #include <vector> #include <algorithm>using namespace std;vector<int> v[270000];int getbigindex(char s[]) {return (s[0] - A…

1033. To Fill or Not to Fill (25)

1033. To Fill or Not to Fill (25)#include <iostream> #include <algorithm>using namespace std;struct node {double dis, p; }stations[510];int cmp(node n1, node n2) {return n1.dis < n2.dis;…

1032. Sharing (25)

1032. Sharing (25)#include <iostream> #include <vector>using namespace std;struct node {int address, next;char data; }nod[100000];int main() {int begin[2], n;scanf("%d%d%d", &…

1031. Hello World for U (20)

1031. Hello World for U (20)#include <iostream> #include <string.h>using namespace std;int main() {char s[100];gets(s);int n1, n2, n = strlen(s), flag = 0;for(n2 = 3; n2 <= n; n2++){for(…

1034. Head of a Gang (30)

1034. Head of a Gang (30)#include <iostream> #include <vector> #include <algorithm>using namespace std;int tree[2010], sum[2010], smallindex[2010], bigindex[27000], weight[2010], cur,…

2025 年 11 月工业加湿器厂家权威推荐榜:高压微雾/干雾/纺织/印刷加湿器,喷雾降尘/喷雾造景/喷雾除臭设备,车间/电子车间/冷库加湿系统精选

2025 年 11 月工业加湿器厂家权威推荐榜:高压微雾/干雾/纺织/印刷加湿器,喷雾降尘/喷雾造景/喷雾除臭设备,车间/电子车间/冷库加湿系统精选 随着工业环境控制要求的不断提高,工业加湿器在现代化生产过程中扮演着越…

1021. Deepest Root (25)

1021. Deepest Root (25)#include <iostream> #include <queue> #include <vector> #include <string.h>using namespace std;int vis[10010], sum[10010], tree[10010], level; queue<int…

Error: Internal Error: Sub-system: FDI_DATA——Cyclone 10 gx编译报错

Error: Internal Error: Sub-system: FDI_DATA——Cyclone 10 gx编译报错错误提示:Error: Internal Error: Sub-system: FDI_DATA, File: /quartus/ddb/fdi/fdi_timing_model.cpp, Line: 753 Error - could not find …

反悔贪心题目总结

模拟费用流 单向链模型、双向链模型 经典例题 反悔贪心&模拟费用流 - Xun_Xiaoyao 反悔贪心(模拟费用流) - Xttttr CF865D Buy Low Sell High P11457 [USACO24DEC] Job Completion G P4053 [JSOI2007] 建筑抢修 …

1012. The Best Rank (25)

1012. The Best Rank (25)#include <iostream> #include <algorithm>using namespace std;struct node {int id, score[5]; }stu[2010];int flag[1000000], bestrankindex[1000000], cmpindex;int cmp(nod…

1016. Phone Bills (25)

1016. Phone Bills (25)#include <iostream> #include <map> #include <string> #include <string.h> #include <vector> #include <algorithm>using namespace std;struct node …

人工智能之数据分析 numpy:第二章 简介与安装

人工智能之数据分析 numpy:第二章 简介与安装人工智能之数据分析 numpy 第二章 简介与安装@目录人工智能之数据分析 numpy前言一、NumPy 的主要特点二、安装 NumPy方法 1:使用 pip 安装(推荐)方法 2:使用 conda 安…

2025 年 11 月武汉废旧金属回收厂家权威推荐榜:不锈钢/钛钢,模具钢,废铁/废铜/废铝/铝合金,旧电缆,废旧物资及厂房拆除专业服务

2025 年 11 月武汉废旧金属回收厂家权威推荐榜:不锈钢/钛钢,模具钢,废铁/废铜/废铝/铝合金,旧电缆,废旧物资及厂房拆除专业服务 一、行业背景与发展趋势 随着我国循环经济战略的深入推进,废旧金属回收行业正迎来前所…