【1048】Find Coins (25 分)

简介: 【1048】Find Coins (25 分)【1048】Find Coins (25 分)
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<algorithm>  
#include<map>
#include<vector>
#include<queue> 
using namespace std;
const int N=1005;
int HashTable[N]={0};//存放每个数字出现的次数
int main(){   
  int n,m,a;
  scanf("%d %d",&n,&m);
  for(int i=0;i<n;i++){
    scanf("%d",&a);
    ++HashTable[a];
  }
  for(int i=1;i<m;i++){
    if(HashTable[i]&&HashTable[m-i]){//如果这两个元素存在
      if(i==m-i && HashTable[i]<=1){//要保证类似7+7=14情况的7不唯一
          continue;
      }
      printf("%d %d\n",i,m-i);
      return 0;
    }
  }
  printf("No Solution\n");
  system("pause");
  return 0;
}
相关文章
LeetCode contest 187 1437. 是否所有 1 都至少相隔 k 个元素 Check If All 1's Are at Least Length K Places Away
LeetCode contest 187 1437. 是否所有 1 都至少相隔 k 个元素 Check If All 1's Are at Least Length K Places Away
【1093】Count PAT‘s (25分)【递推】
若直接暴力解会超时!! 可以先算出T的个数(一层for
86 0
【1075】PAT Judge (25 分)
【1075】PAT Judge (25 分) 【1075】PAT Judge (25 分)
88 0
|
人工智能
HDOJ/HDU 2710 Max Factor(素数快速筛选~)
HDOJ/HDU 2710 Max Factor(素数快速筛选~)
80 0
LeetCode 167:两数之和 II - 输入有序数组 Two Sum II - Input array is sorted
公众号: 爱写bug(ID:icodebugs) 给定一个已按照升序排列 的有序数组,找到两个数使得它们相加之和等于目标数。 函数应该返回这两个下标值 index1 和 index2,其中 index1 必须小于 index2。
943 0
|
前端开发
[math skill]Permutation Test 置换检验
显著性检验通常可以告诉我们一个观测值是否是有效的,例如检测两组样本均值差异的假设检验可以告诉我们这两组样本的均值是否相等(或者那个均值更大)。
1801 0
1048. Find Coins (25)
#include #include #include #include using namespace std; map ma; int main(){ int n, m, t; cin >> n ...
860 0