川川加油冲冲冲 level
获赞
31
粉丝
23
关注
11
看过 TA
746
电子科技大学
2025
Java
IP属地:四川
暂未填写个人简介
私信
关注
第一次牛客平台要双机位的,没有手机支架到处去借,过了十来分钟才开始。然后就一直卡在第二题了,最后暴力法只鼓捣出了20%,太菜了。有大佬能给我讲讲怎么做import java.util.Scanner;public class Main {    public static void main(String[] args) {        Scanner in = new Scanner(System.in);        int n = in.nextInt();        int count = 0;        for(int i = 0; i             long num = in.nextLong();            if(findMethod(num)) {                count++;            }        }        System.out.println(count);    }    private static boolean findMethod(long num) { // num >= 1 && num         long[] isPrime = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};        // 判断num能否被isPrime数组中的数整除3次以上        int count = 0;        for(long i : isPrime) {            while(num != 1 && num % i == 0) {                count++;                num /= i; if(count >= 3) return true;            }        }        return false;    }}
投递盒马等公司7个岗位
0 点赞 评论 收藏
转发
牛客网
牛客企业服务