|
|
|
|
讨论 Discussion |
|
|
666 |
#include<cmath>
#include<iostream>
int sushu(int x){
int i,j,f=1;
for(i=2;i<=int(sqrt(x));i++){
if(x%i==0){f=0;break;}
}
return f;
}
int huiwen(int x){
int i=0,j,f=1,s,t,c[20]={0};
s=x;
while(s>0){i++;c[i]=s%10;s=s/10;}
for(j=1;j<=i/2;j++)if(c[j]!=c[1+i-j]){f=0;break;}
return f;
}
using namespace std;
int main(){
//freopen("p1642.in","r",stdin);
//freopen("p1642.out","w",stdout);
int i,j,k,n,s,x=0,y=0,p,t,f=0,d=0;
cin>>s; n=s;
y=n;
if (y%2==0)y++;
do{
y+=2;
if(sushu(y)&&huiwen(y)){cout<<y;break;}
}while(1==1);
//fclose(stdin);
//fclose(stdout);
return 0;
}
( ) |
zzz |
#include<cmath>
#include<iostream>
int sushu(int x){
int i,j,f=1;
for(i=2;i<=int(sqrt(x));i++){
if(x%i==0){f=0;break;}
}
return f;
}
int huiwen(int x){
int i=0,j,f=1,s,t,c[20]={0};
s=x;
while(s>0){i++;c[i]=s%10;s=s/10;}
for(j=1;j<=i/2;j++)if(c[j]!=c[1+i-j]){f=0;break;}
return f;
}
using namespace std;
int main(){
freopen("p1642.in","r",stdin);
freopen("p1642.out","w",stdout);
int i,j,k,n,s,x=0,y=0,p,t,f=0,d=0;
cin>>s; n=s;
y=n;
if (y%2==0)y++;
do{
y+=2;
if(sushu(y)&&huiwen(y)){cout<<y;break;}
}while(1==1);
fclose(stdin);
fclose(stdout);
return 0;
}
( )
|
|
|
|
|
|
|
|
|
|
Flag |
|
题号 |
P1642 |
|
模拟 |
通过 |
52人 |
提交 |
227次 |
通过率 |
23% |
难度 |
1 |
|
|
|
|
|
|