Solution:
/*Chef and Walking on the rectangle*/
#include<stdio.h>
int main()
{
int K,M,N,T;
scanf("%d",&T);
while(T--)
{
scanf("%d %d %d",&N,&M,&K);
if(((N==1) && (M<=2)) || ((N<=2) && (M==1)))
printf("0\n");
else if((N==1) || (M==1))
printf("%d\n",K);
else
printf("%d\n",(K/2)+(K&1));
}
return 0;
}
{
int K,M,N,T;
scanf("%d",&T);
while(T--)
{
scanf("%d %d %d",&N,&M,&K);
if(((N==1) && (M<=2)) || ((N<=2) && (M==1)))
printf("0\n");
else if((N==1) || (M==1))
printf("%d\n",K);
else
printf("%d\n",(K/2)+(K&1));
}
return 0;
}
No comments:
Post a Comment