题目描述
本题为填空题,只需要算出结果后,在代码中使用输出语句将所填结果输出即可。
如果一个正整数只有 11 和它本身两个约数,则称为一个质数(又称素数)。
前几个质数是:2,3,5,7,11,13,17,19,23,29,31,37,⋅⋅⋅ 。
如果一个质数的所有十进制数位都是质数,我们称它为纯质数。例如:2,3,5,7,23,37 都是纯质数,而 111,13,17,19,29,31 不是纯质数。当然 1,4,351,4,35 也不是纯质数。
请问,在 1 到 20210605 中,有多少个纯质数?
运行限制
- 最大运行时间:1s
- 最大运行内存: 256M
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
/*int ans=0;
for(int i=2;i<=20210605;i++){
if(check1(i)){
if(check2(i)){
ans++;
}
}
}
System.out.println(ans);
}
public static boolean check1(int n){
if(n==1||n==0){
return false;
}
for(int i=2;i<=Math.sqrt(n);i++){
if(n%i==0){
return false;
}
}
return true;
}
public static boolean check2(int n){
while(n>0){
int y=n%10;
if(!check1(y)){
return false;
}
n=n/10;
}
return true;*/
System.out.println(1903);
}
}
1411

被折叠的 条评论
为什么被折叠?



