# 111. 构造二阶行列式

暴力模拟就好,每个数不超过 20, 暴力枚举其实也没多大。

#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    for (int x = 1; x <= 20; x++) {
        for (int y = 1; y <= 20; y++) {
            for (int i = 1; i <= 20; i++) {
                for (int j = 1; j <= 20; j++) {
                    if ((x * j - y * i) == n) {
                        cout << x << " " << y << endl; 
                        cout << i << " " << j << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << -1 << endl;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
上次更新:: 3/4/2025, 5:49:45 PM
@2021-2025 代码随想录 版权所有 粤ICP备19156078号