jej333
查看原帖
jej333
1064094
jej333楼主2025/2/6 22:39
#include<bits/stdc++.h>
using namespace std;
int a;
bool z(int x){
	if(x<=1) return 0;
	for(int i=2;i<x;i++){
		if(x%i==0) return 0;
	}
	return 1;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	cin>>a;
	for(int i=pow(10,a-1)+1;i<=pow(10,a-1)*10-1;i+=2){
		int b=i;
		bool c=0;
		while(b){
			if(!z(b)){
				c=1;
				break;
			}
			b/=10;
		}
		if(c==0) cout<<i<<'\n';
	}
	return 0;
}

A了前两个点,T了后面三个,求助优化

2025/2/6 22:39
加载中...