//开方的题不知道为什么不对 public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n, m; while(sc.hasNext()) { n = sc.nextInt(); m = sc.nextInt(); int count_n = getSquareNum(n); int count_m = getSquareNum(m); int i = 1; int res = 0; while(i <= n && i <= m) { if(judgeSquare(i)) { res += count_n; res += count_m; count_n--; count_m--; res--; } else { res += getSquareNum(n / i); res += getSquareNum(m / i); res--; } i++; } System.out.println(res); } sc.close(); } public static int getSquareNum(int n) { return (int) Math.floor(Math.sqrt(n)); } public static boolean judgeSquare(int n) { return Math.sqrt(n) % 1 == 0; } }
点赞 评论

相关推荐

11-18 09:44
Java
小白也想要offer:简历别放洋屁,搞不还还放错了,当然你投外企除外,以上纯属个人观点
点赞 评论 收藏
分享
牛客网
牛客企业服务