Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Newton4566

Problemset: จับคู่เลขมงคล

Language: cpp

Time: 0.004 second

Submitted On: 2026-09-25 15:26:26

#include <bits/stdc++.h>
using namespace std;


int main() {
    int n;
    cin >> n;
    int bd[n];

    for (int i = 0; i < n; i++) {
        cin >> bd[i];
    }

    int lucky;
    cin >> lucky;

    vector<pair<int, int>> luckPair;

    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            if (i == j) continue;
            if (bd[i] + bd[j] == lucky) {
                pair<int, int> temp = {bd[i], bd[j]};
                luckPair.push_back(temp);
            }
        }
    }

    if (!luckPair.empty()) {
        for (pair<int, int> p : luckPair) {
            cout << p.first << ' ' << p.second << endl; 
        }
    } else {
        cout << "No" << endl;
    }

    return 0;
}