Topcoer-single round-RandomColoringDiv2





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;
}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值