10 solutions
-
3
#include<bits/stdc++.h> using namespace std; bool ss(int x){ for(int i=2;i<=x/2;i++){ if(x%i==0) return false; } return true; } bool hw(int x){ int n; n=x%10*100+x/10%10*10+x/100; if(n==x) return true; return false; } int main(){ for(int i=100;i<=999;i++){ if(ss(i)&&hw(i)) cout<<i<<endl; } return 0; }
其实可以直接输出答案的...
-
1
#include<iostream> using namespace std; bool sushu(int x)//判断素数 { for(int i=2;i<=x/2;++i) { if(x%i==0) return false; } return true; } bool huiwen(int x)//判断回文 { int m,w; m=x/100; w=x%10; if(m==w) return true; return false; } int main() { for(int i=100;i<=999;++i) { if(sushu(i)&&huiwen(i)) cout<<i<<endl; } return 0; } //打表版 //#include <bits/stdc++.h> //using namespace std; //int main() //{ // printf("101\n131\n151\n181\n191\n313\n353\n373\n383\n727\n757\n787\n797\n919\n929"); // return 0; //}
-
0
#include <bits/stdc++.h> using namespace std; bool su(int n); bool huiwen(int n); int main(int argc, char **argv){ for (int i = 100;i <= 999;i++){ if (su(i) && huiwen(i)){ printf("%d\n",i); } } return 0; } bool su(int n){ for (int i = 2;i < n;i++){ if (n % i == 0){ return 0; } } return 1; }bool huiwen(int n){ int g = n % 10,b = n / 100; if (g == b){ return 1; } return 0; }
打败哦太简单了,还是做程序好
-
-3
#include<iostream> using namespace std; bool chkprime(int z)//判断素数 { for(int i=2;i<z;++i) { if(z%i==0) return false; } return true; } bool chkback(int y)//判断回文 { int a,c; a=y/100; c=y%10; if(a==c) return true; return false; } int main() { for(int i=100;i<=999;++i) { if(chkprime(i)&&chkback(i)) cout<<i<<endl; } return 0;//OK! }
- 1
Information
- ID
- 641
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 4
- Tags
- # Submissions
- 103
- Accepted
- 48
- Uploaded By