#include <stdio.h>
int where[6][2]; //[0]=변의 방향 [1]=변의 길이
void line(void); //정렬
int size(void); //참외밭의 넓이를 구하는 함수
int main(void)
{
int k, i, sum; //k=1미터제곱의 넓이에 자라는 참외의 개수
scanf("%d", &k);
for(i=0; i<6; i++)
{
scanf("%d", &where[i][0]);
scanf("%d", &where[i][1]);
}
line();
sum=size();
printf("%d", sum*k);
return 0;
}
void line(void)
{
int i, num[4]={0}, n[2], k=0, temp1, temp2;
for(i=0; i<6; i++)
{
num[where[i][0]]++;
if(num[where[i][0]]==2)
n[k++]=where[i][0];
}
while(where[5][0]!=num[0] && where[5][0]!=num[1])
{
temp1=where[5][0];
temp2=where[5][1];
for(i=4; i>=0; i--)
{
where[i+1][0]=where[i][0];
where[i+1][1]=where[i][1];
}
where[0][0]=temp1;
where[0][1]=temp2;
}
}
int size(void)
{
int sum, cut, i, x=0, y=0;
for(i=0; i<6; i++) //가로 세로 길이
{
if(where[i][0]==1)
x+=where[i][1];
else if(where[i][0]==3)
y+=where[i][1];
}
sum=x*y;
//printf("x=%d y=%d sum=%d \n", x, y, sum);
for(i=0; i<6; i++) //파인 부분의 넓이
{
where[i][0]--;
if((where[i][0]/2)==0 && where[i][1]<x)
{
cut=where[i+1][1]*where[i+2][1];
break;
}
else if((where[i][0]/2)==1 && where[i][1]<y)
{
cut=where[i+1][1]*where[i+2][1];
break;
}
}
sum-=cut;
//printf("x=%d y=%d sum=%d cut=%d \n", x, y, sum, cut);
return sum;
}
2018.01.27 09:50
정올 - 실력키우기 - 참외밭(2259)
조회 수 641 추천 수 0 댓글 0