标签:多少 params ret rgb 输出 大于 sum math ble
求11到n之间(包括n),既是素数又是回文数的整数有多少个。
23
1
1 #include<iostream> 2 #include<cmath> 3 #include<algorithm> 4 using namespace std; 5 int sushu(int x) 6 { 7 int i=2; 8 while(i<sqrt(x)&&x%i!=0) 9 { 10 i++; 11 } 12 if(i>sqrt(x)&&x!=1) 13 { 14 return 1; 15 } 16 else 17 { 18 return 0; 19 } 20 } 21 int huiwen(int x) 22 { 23 int sum=0; 24 while(x) 25 { 26 sum=sum*10+x%10; 27 x/=10; 28 } 29 return sum; 30 } 31 int main() 32 { 33 int r,t=0; 34 cin>>r; 35 for(int i=11;i<=r;++i) 36 { 37 if(sushu(i)&&huiwen(i)==i) 38 t++; 39 } 40 cout<<t; 41 return 0; 42 }
标签:多少 params ret rgb 输出 大于 sum math ble
原文地址:https://www.cnblogs.com/dss-99/p/14241093.html