有人能解释一下这个java代码吗
这是一个由Zyflair提供的解决方案 我不能理解代码或者它是如何工作的,有人能解释它或者简化它吗有人能解释一下这个java代码吗,java,Java,这是一个由Zyflair提供的解决方案 我不能理解代码或者它是如何工作的,有人能解释它或者简化它吗 public int countSupervisors(int[] students, int Y, int J){ for(int i = 0,Y2 = Y + (Y = 0),J2=J+(J=0) ;i<students.length; i++,Y +=students [i -1 ] ){ J =Math.max(J,-(Math.max(0, students[i]-Y2)
public int countSupervisors(int[] students, int Y, int J){
for(int i = 0,Y2 = Y + (Y = 0),J2=J+(J=0) ;i<students.length; i++,Y +=students [i -1 ] ){
J =Math.max(J,-(Math.max(0, students[i]-Y2)+J2-1)/J2+(students[i] = (students[i]+J2-1)/J2));
}
return Y-J;
}
public int countSupervisors(int[]学生,int Y,int J){
对于(inti=0,Y2=Y+(Y=0),J2=J+(J=0);我现在没有时间研究这个问题,但这里有一点简化:
// Y2 = Y + (Y = 0)
int Y2 = Y;
Y = 0;
// J2 = J + (J = 0)
int J2 = J;
J = 0;
// Note that, since we've just set Y and J to 0,
// we may as well have used different variables
for (int i = 0; i < students.length; i++)
{
int temp = (students[i] + J2 - 1) / J2;
J = Math.max(J, -(Math.max(0, students[i] - Y2) + J2 - 1) / J2 + temp);
Y += temp;
}
return Y-J;
//Y2=Y+(Y=0)
int Y2=Y;
Y=0;
//J2=J+(J=0)
int J2=J;
J=0;
//注意,因为我们刚刚将Y和J设置为0,
//我们不妨使用不同的变量
for(int i=0;i
这是一段多么糟糕的代码。竞争对手通常这样做,因此他们的代码很难理解(因此也很难挑战)。问题描述是什么?多了解一些上下文会有帮助。你能发布问题或将其链接吗?我不会称其作者为“顶级程序员”.问题在这里不。没有人能解释这个代码。谢谢,这帮了大忙