Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
98576 王思颜 素数对 C++ Accepted 38 MS 276 KB 413 2024-11-23 11:40:40

Tests(10/10):


Code:

#include<bits/stdc++.h> using namespace std; int he(int b){ if (b < 2){ return 0; } for (int i = 2;i < b;i++){ if (b % i == 0){ return 0; } } return 1; } int main(){ int n,a,b,x = 0; cin>>n; for (int j = 2;j <= n - 2;j++){ a = he(j); b = he(j + 2); if (a == 1 && b == 1){ cout<<j<<" "<<j + 2<<endl; } x++; } if (x == 0){ cout<<"No"; } return 0; }