Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
159670 张晓冉 素数对 C++ Accepted 9 MS 264 KB 478 2026-09-06 14:04:15

Tests(10/10):


Code:

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