Java笔试机考必备技能Scanner类常用操作_牛客面试scanner教学-CSDN博客
16-1-Java常用类之Scanner【干货笔记】_java 输入函数scanner面试题-CSDN博客
Scanner next() Scanner nextInt() Scanner nextLine() 区别

携程26春招笔试-拆盲盒
主要练下 Scanner sc = new Scanner(System.in)
int a = sc.nextInt();
while(a-->0){
xxx
}
sc.close();
System.ouyt.println(xxx);
java
package com.example;
import java.util.*;
public class Xiec_test2 {
public static long solveOne(long n,long m){
long y = m;
return (n- y)/2;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
while(a-- >0){
long b = sc.nextLong();
long c = sc.nextLong();
System.out.println("hh" + solveOne(b,c));
}
sc.close();
}
}
26美团 因子数量
java
package com.example;
import java.util.*;
public class Meit_test1 {
public static long count(long l,long r){
return floorSqrt(r) - floorSqrt(l-1);
}
public static long floorSqrt(long x){
long t = (long) Math.sqrt(x);
while((t+1)*(t+1)<=x){
t++;
}
while(t*t>x){
t--;
}
return t;
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
long l = sc.nextLong();
long r = sc.nextLong();
System.out.println(count(l,r));
}
}