想帮忙看一下为什么第四个数据总是错的(这个格式是在练习所以看起来有点复杂)
查看原帖
想帮忙看一下为什么第四个数据总是错的(这个格式是在练习所以看起来有点复杂)
1292550
wwxb1楼主2024/3/3 20:40

import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int m, t, s;
		m = reader.nextInt();
		t = reader.nextInt();
		s = reader.nextInt();
		Apple sum = new Apple(m, t, s);
		int rest = sum.Sum(sum);
		if (rest < 0)
			rest = 0;
		System.out.println(rest);
	}
}

class Apple {
	int a, b, c;

	Apple(int x, int y, int z) {
		a = x;
		b = y;
		c = z;
	}

	Apple() {

	}

	int Sum(Apple f) {
		int rest;
		if (f.b == 0 || f.a * f.b <= f.c) {
			rest = 0;
		} else {
			rest = a - (int) Math.ceil(f.c / f.b);
		}
		return rest;
	}
}

2024/3/3 20:40
加载中...