Submission

Status:

PPPPPPPPPPPPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: solarsunny

Problemset: จำนวนเฉพาะก่อนหน้า

Language: cpp

Time: 0.002 second

Submitted On: 2025-10-12 23:27:24

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int c=0;
    int x=n;
    int a[5];
    while (c<5) {
        x--;
        bool prime= true;
        for(int i=2; i*i<=x; i++) {
            if(x%i==0) {
                prime = false;
                break;
            }
        }
        if(prime) {
            a[4-c] = x;
            c++;
        }
    }
    for(int i=0; i<5; i++) {
        cout << a[i] << " ";
    }
    cout << "\n";
    
}