Silencer76的精华题解实在精妙,x>1时,必定有数对(x,x)满足条件。

这里我给出我自己在探索时找到的另外一个规律:

#include <cmath>
#include <iostream>
#include <linux/limits.h>
using namespace std;

int main() {
    int x;
    cin >> x;
    // a % b = 0
    // a * b > x
    // a / b < x
    
    // x=1, -1
    // x=2, a=2,b=2
    // x=3, a=2,b=2
    // x=4, a=4,b=2
    // x=5, a=4,b=2
    // x=6, a=4,b=2
    // x=7, a=4,b=2
    // x=8, a=8,b=2
    // x=9, a=8,b=2
    // x=10,a=8,b=2
    // x=11,a=8,b=2
    // x=12,a=8,b=2
    // 不难发现,我们需要一个2^n次方,满足小于等于x且它的值尽可能大,那么必定a=2^n,b=2,找到解
    if (x == 1) {
        cout << -1;
    }
    else {
        int power = 0;
        long long value = 1;  // 2^0
        while (value <= x) {
            value <<= 1;  // 相当于 value *= 2
        }
        cout << value/2 << " " << 2;
    }
}