Submission
Status:
----------
Subtask/Task Score:
0/100
Score: 0
User: Songkran
Problemset: จับคู่เลขมงคล
Language: cpp
Time: 0.003 second
Submitted On: 2025-09-29 10:25:54
// #include <bits/stdc++.h>
// using namespace std;
// int main(){
// int n,ln,c=0;
// cin >> n;
// int arr[n];
// for (int i = 0; i < n; i++){
// cin >> arr[i];
// }
// cin >> ln;
// for (int i = 0; i < n; i++){
// for (int j = i+1; j < n; j++){
// if (arr[i] + arr[j] == ln){
// cout << arr[i] << " " << arr[j] << endl;
// c++;
// }
// }
// }
// if (c == 0){
// cout << "no";
// }
// return 0;
// }
#include <bits/stdc++.h>
using namespace std;
int main(){
int n, ln;
cin >> n;
vector<int> arr(n);
for (int i = 0; i < n; i++){
cin >> arr[i];
}
cin >> ln;
set<pair<int,int>> s; // store unique pairs
for (int i = 0; i < n; i++){
for (int j = i+1; j < n; j++){
if (arr[i] + arr[j] == ln){
int a = min(arr[i], arr[j]);
int b = max(arr[i], arr[j]);
s.insert({a, b});
}
}
}
if (s.empty()){
cout << "no";
} else {
for (auto p : s){
cout << p.first << " " << p.second << endl;
}
}
return 0;
}