社区讨论
90分一个TLE求调
P1217[USACO1.5] 回文质数 Prime Palindromes参与者 2已保存回复 2
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 2 条
- 当前快照
- 1 份
- 快照标识符
- @mlhceswj
- 此快照首次捕获于
- 2026/02/11 09:20 上周
- 此快照最后确认于
- 2026/02/11 10:30 上周
CPP
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,n;
cin>>a>>n;
for(int i=a;i<=n;i++){
string s=to_string(i);
string s2=s;
int f=0;
reverse(s.begin(),s.end());
if(s==s2)f=1;
for(int j=2;j*j<=i and f;j++){
if(i%j==0)f=0;
}
if(f)cout<<i<<'\n';
}
return 0;
}
回复
共 2 条回复,欢迎继续交流。
正在加载回复...