r最大1e8,直接枚举肯定超时啊 @[LZY109469](/user/1045442)
by zhang_feng_rui @ 2024-03-20 12:55:19
打错了,是b
by zhang_feng_rui @ 2024-03-20 12:55:55
@[LZY109469](/user/1045442) 特判偶数
```
#include <bits/stdc++.h>
using namespace std;
long long x, y;
bool cou(int x) {
for (int i = 2; i <= sqrt(x); i++)
if (x % i == 0)
return false;
return true;
}
bool co(long long x) {
long long a[20] = {0}, f = 1;
while (x) {
a[f] = x % 10, x /= 10, f++;
}
for (int i = 1; i <= f / 2; i++)
if (a[i] != a[f - i])
return false;
return true;
}
int main() {
cin >> x >> y;
for (int i = x; i <= y; i++) {
if (i % 2 == 0 && i != 2) {
continue;
}
if (co(i) && cou(i)) {
cout << i << endl;
}
}
return 0;
}
```
~~求关~~
by C13408964921 @ 2024-03-20 13:01:11
@LZY109469,实在不行,提交时用c++ 98 O2(
by jiangyunlong @ 2024-03-20 13:04:02
@[zhang_feng_rui](/user/1061189) 谢谢
by LZY109469 @ 2024-03-20 13:24:29
@[C13408964921](/user/766647) 已经OK了
by LZY109469 @ 2024-03-20 13:24:58
@[jiangyunlong](/user/867938) ok
by LZY109469 @ 2024-03-20 13:25:14