Luke is trying to solve the puzzle problem during Mathematics class hour. He has a graph paper with G X N rows and columns, and the puzzle question is, an NCC training base in each cell for a total of G X N bases. He wants to drop food items to every point based on strategic points on the graph paper, marking each drop point with a red dot. If a base contains at least one food package inside or on top of its border fence, then it’s considered to be supplied.
For example: if Luke has four bases in a 2×2 grid. If he drops a single food package where the walls of all four bases intersect, then those four cells can access the food package.
Given G and N, what’s the minimum number of packages that Luke must drop to supply all of his bases?
Example :
G=2, N=3.
Food Packages can be dropped at the corner between cells (0, 0), (0, 1), (1, 0), (1, 1) , (0, 2) and (1, 2). This supplies all bases using packages.
Function Description:
- G: the number of rows
- N: the number of columns
Input:
Two space-separated integers describing the respective values of G and N.
Output:
The only line of output has single integer indicating the minimum number of food packages required
Explanation
Luke has four bases in a 2X2 grid. If he drops a single package where the walls of all four bases intersect, then those four cells can access the package:
Because he managed to supply all four bases with a single supply drop, we print 1 as our answer.
#include <stdio.h> int NccCells(int x,int y) {int package; package=((x+1)/2)*((y+1)/2); return package; } int main() {int G,N; scanf("%d %d",&G,&N); int package; package=NccCells(G,N); printf("%d",package); return 0; }
INPUT_1:
2 2
OUTPUT:
1
INPUT_2:
1 4
OUTPUT:
2
Morae Q!
- Find how long will it take till the next fortune year from the current year.
- Find if it’s possible to distribute all the crayons into boxes and satisfy all the conditions.
- Compute sum of numbers using call by reference.
- Compute the amount of money to be handed over with conditions.
- Find the total number of beautiful triplets in the sequence.
- Find the total amount each worker has to pay individually.
- Find the minimum distance between any pair of equal elements in the array.
- Compute the maximum possible value of the given equation.
- Find the age of the student at the time of joining.
- Compute the total number of photos at each restaurant .
- Find the sum of digits of the number using Union datatype.
- Generate the details of the novels in the expected format.
- Sort the student details based on their names in ascending order.
- Find a way to move the king from current position to different square on chessboard.
- Find the time differences in the two different time zones.
- Identifying the greatest number with a numerator and denominator.
- Find the Minimum number of packages to supply all the bases.
- Tower of Hanoi, A puzzle.
- Compute the sum of array of elements using recursion method.
- Find the super digit of an integer using the rules.