注意开浮点数
import java.util.Scanner; public class Main { static Scanner sc=new Scanner(System.in); public static void main(String[] args) { double t=0; int cnt=0; double distance=1000; while(distance>=1){ //相撞时间 t=distance/60.0; distance-=t*20; cnt++; } System.out.println(cnt/2); } }