第一题AC,注意点:输入是long类型,不能用BufferedReader,不然很麻烦:
1 public class Main { 2 3 public static void main(String[] args) throws IOException { 4 Scanner in = new Scanner(System.in); 5 long x = in.nextLong(); 6 long f = in.nextLong(); 7 long d = in.nextLong(); 8 long p = in.nextLong(); 9 long last = d - x * f; 10 if(last > 0) { 11 long day = last / (x + p); 12 System.out.println(day + f); 13 } 14 //如果钱还不够付初始房费的 15 else { 16 long day = d / x; 17 System.out.println(day); 18 } 19 } 20 21 }