Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: PEPSEALSEA

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

Language: cpp

Time: 0.003 second

Submitted On: 2025-10-13 11:30:31

#include <bits/stdc++.h>

using namespace std;

int main(){
    int n = 0;
    cin >> n;

    int allNum[n+1] = {0};
    for (int i = 0; i < n; i++){
        cin >> allNum[i];
        // if (allNum[i]<1||allNum[i]>30){
        //     cout << "No";
        //     return 0;
        // }
    }
    
    int needNum = 0;
    cin >> needNum;

    bool check = false;

    // if(needNum<2 || needNum>30){
    //     cout << "No";
    //     return 0;
    // }

    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            if((allNum[i]+allNum[j]) == needNum){
                cout << allNum[i] << " " << allNum[j] << "\n";
                check = true;
            }
        }
    }

    if (!check){
        cout << "No\n";
    }

    return 0;
}