21 条题解

  • 0
    @ 2025-6-5 15:50:27

    #include using namespace std; bool isPrime(int x) { if(x < 2) return false; for(int i = 2; i * i <= x; i++) { if(x % i == 0) return false; } return true; } int main() { int n; cin >> n; bool found = false; for(int i = 2; i + 2 <= n; i++) { if(isPrime(i) && isPrime(i + 2)) { cout << i << " " << i + 2 << endl; found = true; } } if(!found) { cout << "empty"; } return 0; }

    信息

    ID
    946
    时间
    1000ms
    内存
    128MiB
    难度
    7
    标签
    (无)
    递交数
    1291
    已通过
    347
    上传者