#7 #10 WA,求调
  • 板块B2132 素数对
  • 楼主EL_C
  • 当前回复4
  • 已保存回复4
  • 发布时间2024/9/29 20:19
  • 上次更新2024/9/29 21:53:00
查看原帖
#7 #10 WA,求调
1457405
EL_C楼主2024/9/29 20:19
#include <bits/stdc++.h>
using namespace std;
long long su(int x){
	if(x==1) return 0;
	if(x==2) return 1;
	for(int i=2;i<=sqrt(x);i++){
		if(x%i==0){
			return 0;
		}
	}
	return 1;
}
int main() {
	int n,cnt=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		if(su(i)==true&&su(i+2)==true){
			cout<<i<<" "<<i+2<<endl;
			cnt++;
		}
	}
	if(cnt==0){
		cout<<"empty";
	}
	return 0;
}
2024/9/29 20:19
加载中...