关于数据

P1579 哥德巴赫猜想(升级版)

gjrBJ @ 2025-01-10 22:51:52

竟然不会TLE??? 我故意写的O(n^4)

#include<bits/stdc++.h>
using namespace std;
int n;
bool check(int x) {
    if (x <= 1) return false;
    for (int i = 2; i < x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}
int main() {
    cin >> n;
    for (int i = 2; i <= n; i++) {
        for (int j = 2; j <= n; j++) {
            for (int k = 2; k <= n; k++) {
                if (i + j + k == n && check(i) && check(j) && check(k)) {
                    cout << i << " " << j << " " << k << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

非常不理解为什么这个代码会\colorbox{black}{\textcolor{lightgreen}{AC}}


by cff_0102 @ 2025-01-10 22:58:26

开 O2 导致的


by gjrBJ @ 2025-01-10 23:11:12

EM...

|