笔试的Scanner in Scanner out

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));

    }
}
相关推荐
南城以南溫暖如初1471 小时前
社交裂变商城系统设计与实战开发指南
java·spring boot·mysql·vue·mybatis
Zane1994121 小时前
HashSet、TreeSet、LinkedHashSet:底层都是“套壳“
java·开发语言
xiaoqiMikko1 小时前
Spring 官方给 5.3 线开了三个修复版,Maven Central 上一个都没有
java·spring boot
南城以南溫暖如初1472 小时前
分享返现商城系统开发实战:技术架构与运营经验指南
java·spring boot·mysql·架构·vue·mybatis
vipxieliang2 小时前
Java切面编程(AOP)详解:从核心概念到实战应用
java·spring boot
.Hypocritical.2 小时前
SpringBoot 各版本 Profile 多环境配置完整对比(2.x/ 2.4+ / 3.x/4.x
java·spring boot·后端
麻花20132 小时前
Win10、win11清理C盘的bat文件内容
开发语言
露天赏雪2 小时前
掘金小册样章
java·开发语言·人工智能·ai编程
zlwool2 小时前
图纸管理选型:从变更频率到齐套率
java·前端·python·erp·设备erp·非标机械