//开方的题不知道为什么不对 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; } }
点赞 评论

相关推荐

牛客网
牛客企业服务