1 solutions

  • 0
    @ 2025-11-5 18:34:39

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    int n, m ;
    bool pd(int x) {
        if(x == 2) return 1 ;
        for(int i = 2 ; i * i <= x ; i++) if(x % i == 0) return 0 ;
        return 1 ;
    }
    int cal(int x) {
        for(int i = n ; ; i--) if(x % i == 0 && pd(i)) return i ;
    }
    int main() {
        cin >> m >> n ;
        for(int i = m ; i < n ; i++) cout << cal(i) << ',' ;
        cout << cal(n) ;
        return 0 ;
    }
    
    • 1

    Information

    ID
    18934
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    6
    Tags
    # Submissions
    44
    Accepted
    13
    Uploaded By