水题,注意到除了2的所有偶数均为合数,特判一下 x = 1,然后直接输出 2x 即可。

#include<bits/stdc++.h>
using i64 = long long;

int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);

    int n;
    std::cin >> n;
    if (n == 1) {
        std::cout << -1;
        return 0;
    }

    std::cout << 2 * n;

    return 0;
}

https://www.nowcoder.com/discuss/727521113110073344