Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 36641 | Accepted: 12200 |
Description
Input
Output
Sample Input
0 0 4 0 0 1 7 5 1 0 0 0 0 0 0 0 0 0
Sample Output
2 1
package poj;
import java.util.Arrays;
import java.util.Scanner;
public class Poj1017_20120823_0 {
private static int [][] group = new int [][]{
{0},
{1,0},
{2,1,0},
{3,1,0},
{4,0},
{5}
};
private static int [] area = new int[]{1,4,9,16,25,36};
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int [] parcels = new int[6];
int [] choise = new int[6];
boolean b = false;
int i,sum,totalArea,j;
while(true){
b = false;
sum = 0;
totalArea = 36;
for(i = 0; i < 6; ++i){
parcels[i] = in.nextInt();
if(parcels[i] != 0){
b = true;
}
}
if(b){
for(i = 5; i >= 0; --i){
if(parcels[i] > 0){
Arrays.fill(choise, 0);
for(j = 0; j < group[i].length; ++j){
if(parcels[group[i][j]] > 0){
int temp = totalArea/area[group[i][j]];
if(temp > 0&& group[i][j] >= 3){
temp = 1;
}
if(temp >= parcels[group[i][j]]){
temp = parcels[group[i][j]];
}
if(temp != 0){
choise[group[i][j]] = temp;
}
if(group[i][j]==1){
switch (choise[2]){
case 1:
if(temp > 5){
temp = 5;
}
break;
case 2:
if(temp > 3){
temp = 3;
}
break;
case 3:
if(temp > 1){
temp = 1;
}
break;
}
}
totalArea -= temp * area[group[i][j]];
parcels[group[i][j]] -= temp;
if(totalArea == 0){
break;
}
}
}
++sum;
totalArea = 36;
if(parcels[i] > 0){
++i;
}
}
}
System.out.println(sum);
}else{
break;
}
}
}
}
PS: 這個程序我是懶得註釋了,誰要能看懂了,你就要我的偶像。。注意留下姓名。聯繫方式,,自己寫的都無語。