社区讨论
听取WA声一片
B2132素数对参与者 3已保存回复 7
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 7 条
- 当前快照
- 1 份
- 快照标识符
- @mhjkqttt
- 此快照首次捕获于
- 2025/11/04 04:10 4 个月前
- 此快照最后确认于
- 2025/11/04 04:10 4 个月前
CPP
#include<bits/stdc++.h>
using namespace std;
int n;
bool prime(int x)
{
if(x==1) return false;
if(x==2) return true;
int j=2;
while(j*j<=x && x%j!=0) j++;
if(x%j==0) return false;
else return true;
}
bool pd=true;
int main()
{
cin>>n;
for(int i=3;i<=n;i++)
{
if(prime(i) && prime(i-2))
{
cout<<i-2<<" "<<i<<endl;
pd=false;
}
}
if(pd) cout<<"empty"<<endl;
return 0;
}
回复
共 7 条回复,欢迎继续交流。
正在加载回复...