Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
72781 | 彭林江 | 质数的和与积 | C++ | Accepted | 22 MS | 276 KB | 371 | 2024-05-12 18:08:37 |
#include<bits/stdc++.h> using namespace std; int prime(int x){ for(int i = 2; i < x; i++){ if(x % i == 0){ return 0; } } return 1; } int main(){ int n; cin >> n; int mx = -2e9; for(int i = 2; i < n-1; i++){ if(prime(i) == 1 && prime(n-i) == 1){ if(i * (n-i) > mx){ mx = i*(n-i); } } } cout << mx; return 0; }