Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
98555 | 王思颜 | 素数对 | C++ | Wrong Answer | 1 MS | 268 KB | 367 | 2024-11-23 11:32:29 |
#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,m = 0; cin>>n; for (int j = 2;j <= n;j++){ a = he(j); b = he(j + 2); if (a == 1 && b == 1){ cout<<j<<" "<<j + 2<<endl; } } return 0; }
------Input------
17
------Answer-----
3 5 5 7 11 13
------Your output-----
3 5 5 7 11 13 17 19