Tennis Court

QUESTION:

Many of the current final year students of a college are excellent tennis players. They always emerge as champions in the State Level Inter-Collegiate Tennis Meet. They want their juniors to carry on their legacy in the field of tennis and they started training their juniors in tennis. They were happy to see them play very well during their coaching sessions. They had a very comfortable win over one of the top teams in the game played at their college. But to their dismay, their juniors performed very poorly in the games conduced at other venues.

The think-tank of the College Tennis club was pondering over the reasons for their poor performance in the meets.  David came up with a possible reason for the poor performance of their junior team. The tennis court in their college is a grass court but the tennis courts in most other competitive venues are synthetic courts. Their junior team has learnt playing tennis in the grass court and they found it very difficult to adapt their game to synthetic courts. The entire team agreed with this reason and they planned to request the chairman to convert the grass tennis court to synthetic tennis court.

They sent a request to the Chairman and he readily agreed but he asked to do it with minimal expenditure. He gave them square stones.

The tennis court in the college is rectangular in shape of size n*m metres. We need to pave the court with square stones. The square stone is of size a*a.

What is the least number of stones needed to pave the tennis court? It's allowed to cover the surface larger than the Tennis Court, but the court has to be covered. It's not allowed to break the stones. The sides of stones should be parallel to the sides of the court.
Input Format:
Input consists of 3 integers. The first integer corresponds to 'n', the length of the court. The second integer corresponds to 'm', the width of the court. The third integer corresponds to 'a', the side of the square stone.
Output Format:
Output consists of ta single integer k, where k is the least number of stones needed.

Sample Input:
6
6
4

Sample Output:
4

SOLUTION:

#include<stdio.h>
#include<math.h>
int main()
{
    int l,b,la,ba,plate,a;
    scanf("%d",&l);
    scanf("%d",&b);
    scanf("%d",&a);
    la=round((float)l/a);
    ba=round((float)b/a);
    plate=la*ba;
    printf("%d",plate);
    return 0;
}

Comments

Popular posts from this blog

Implementing a Fixed size Queue of maximum size 5 using an array

Implementing a Dynamically sized stack using array

Functions - Null Matrix