public class RandomColoringDiv2 {
public static void main(String args[]) {
new RandomColoringDiv2();
}
public RandomColoringDiv2() {
System.out.println(getCount(6, 9, 10, 1, 2, 3, 4, 10));
}
public int getCount(int maxR, int maxG, int maxB, int startR, int startG,
int startB, int d1, int d2) {
int totalMost = 0;
int sR = (0 >= (startR - d2)) ? 0 : (startR - d2);
int sG = (0 >= (startG - d2)) ? 0 : (startG - d2);
int sB = (0 >= (startB - d2)) ? 0 : (startB - d2);
System.out.println((sR)+" "+(sG)+" "+(sB));
int eR = ((maxR - 1) <= (startR + d2)) ? (maxR - 1) : (startR + d2);
int eG = ((maxG - 1) <= (startG + d2)) ? (maxG - 1) : (startG + d2);
int eB = ((maxB - 1) <= (startB + d2)) ? (maxB - 1) : (startB + d2);
System.out.println((eR)+" "+(eG)+" "+(eB));
int a=(eR-sR+1);
int b=(eG-sG+1);
int c=(eB-sB+1);
if(d1==0){
totalMost=a*b*c;
}
else{
totalMost=a*b*c-getCount2(maxR, maxG, maxB, startR, startG,
startB, d1, d1-1);
}
return totalMost;
}
public int getCount2(int maxR, int maxG, int maxB, int startR, int startG,
int startB, int d1, int d2) {
int totalMost = 0;
int sR = (0 >= (startR - d2)) ? 0 : (startR - d2);
int sG = (0 >= (startG - d2)) ? 0 : (startG - d2);
int sB = (0 >= (startB - d2)) ? 0 : (startB - d2);
System.out.println((sR)+" "+(sG)+" "+(sB));
int eR = ((maxR - 1) <= (startR + d2)) ? (maxR - 1) : (startR + d2);
int eG = ((maxG - 1) <= (startG + d2)) ? (maxG - 1) : (startG + d2);
int eB = ((maxB - 1) <= (startB + d2)) ? (maxB - 1) : (startB + d2);
System.out.println((eR)+" "+(eG)+" "+(eB));
int a=(eR-sR+1);
int b=(eG-sG+1);
int c=(eB-sB+1);
return a*b*c;
}
}