- #include<iostream>
- #include<string.h>
- using namespace std;
- #define max 100000
- int input[max];
- int main()
- {
- int N,M;
- cin>>N>>M;
- int i,j;
- int temp;
- int flag;
- bool find = false;
- memset(input,0,sizeof(input));
- for(i=0; i<N; i++)
- {
- cin>>temp;
- input[temp] ++;
- }
- for(i=0; i<=M/2; i++)
- {
- //以下两行是为了判断是否存在两个同样的数和为题目所求,比如14=7+7;
- input[i]--;
- input[M-i]--;
- if(input[i]>=0 && input[M-i]>=0)
- {
- find = true;
- cout<<i<<" "<<M-i<<endl;
- break;
- }
- }
- if( !find )
- cout<<"No Solution"<<endl;
- return 0;
- }
PAT1048
最新推荐文章于 2023-01-15 21:14:21 发布