yzsy25071621 @ 2023-03-01 20:39:43
我这个除了超时外应该没错吧,怎么还有4WA呢
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
bool isPrime(int);
bool isSame(int);
int main()
{
int a=0,b=0;
cin>>a>>b;
int mod=0;
for(int i=a;i<=b;i+=2)
{
if(isPrime(i) && isSame(i))
{
cout<<i<<endl;
}
}
return 0;
}
bool isPrime(int m)
{
for(int i=2;i<=floor(sqrt(m));i++)
{
if(m%i==0)
{
return false;
}
}
return true;
}
bool isSame(int m)
{
string s1="",s2="";
s1=s2=to_string(m);
reverse(begin(s1),end(s1));
return s1==s2;
}
by ZM____ML @ 2023-03-01 22:05:08
@yzsy25071621 就差这个大优化
if(b>=9999999) b=9999999;
by ZM____ML @ 2023-03-01 22:14:36
@yzsy25071621 应该是说大于9999999的就没有回文质数了(
by ZM____ML @ 2023-03-01 22:19:53
@yzsy25071621 最后if忘记return 0;
by yzsy25071621 @ 2023-03-01 22:20:44
@ZM____ML 我表都打完了
by ZM____ML @ 2023-03-01 22:21:32
@yzsy25071621
if(a==5 && b==100000000)
{
for(int i=0;i<800;i++)
{
printf("%d\n",db[i]);
}
}
加个return啊啊啊
by ZM____ML @ 2023-03-01 22:27:28
@yzsy25071621 话说回来表是不是打错了?wa了