1 solutions

  • 0
    @ 2026-11-15 12:38:05

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    int ysh(int a) {
        int s = 0;
        for (int i = 1; i * i <= a; i++) {
            if (a % i == 0) {
                s += i;
                if (i * i != a)
                    s += a / i;
            }
        }
        return s;
    }
    int main() {
        int n;
        cin >> n;
        for (int i = 1; i < n; i++) {
            if (ysh(i) == n) {
                cout << i;
                return 0;
            }
        }
        cout << "-1";
        return 0;
    }
    
    • 1

    Information

    ID
    187
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By