点击这里更换您喜欢的皮肤wtboj 首页
请点击这里登入noios   首页 入门 c++讲义 入门教程视频 金牌教程 入门视频 站务 公告 | 题库 记录 竞测 测试 闯关 作业 排名 团队 讨论 | 换肤 | 登入 注册  
News >>   新增功能:各团队管理员可以发布本团队作业了 ()

From sina007
回文质数
讨论 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
提交 讨论 题解
 Copyright wtboj © 2005-2006. www.wutuobang.date Powered by wtboj 关于 联系 帮助
 wtboj Information ---- Total Users : 1253 | Online Users / Processes : 0 / 153 | Processed Time : 31 ms | Server Time : 2025/7/1 21:12:31