LHX_18460366315 @ 2024-02-10 12:39:47
这个代码我核对了 N 遍,结果仍然还是没有输出。。。。。。
#include<bits/stdc++.h>
using namespace std;
bool zhishu(long long x){
if (x <= 1){
return false;
}
for (long long i = 1;i <= sqrt(x);i++){
if (x % i == 0){
return false;
}
}
return true;
}
bool check(int x){
int a[20],flag = 1;
while (x > 0){
a[flag] = x % 10;
x /= 10;
flag++;
}
for (int i = 1; i <= flag / 2;i++){
if(a[i] != a[flag - i]){
return false;
}
}
return true;
}
bool weishu(int x){
if((1000 <= x && x <= 9999) || (100000 <= x && x <= 999999)){
return false;
}
return true;
}
int main(){
long long n,m;
cin >> n >> m;
for (long long i = n;i <= m;i += 2){
if (zhishu(i) && check(i) && weishu(i)){
cout << i << endl;
}
}
return 0;
}
by ny_jerry2 @ 2024-02-10 13:20:21
求质数那里有点问题 循环从2开始
by sqz11111 @ 2024-02-12 10:30:19
@ZZYX_18670145320 如果输入的n是偶数 那你就只枚举了偶数呀 要特判一下 如果n是偶数 那就n++
by LHX_18460366315 @ 2024-02-12 13:43:58
@ny_jerry2 哦谢谢