SAP SVNT OA

Jenny owns a fertile rectangular farm land which is (X) meters wide and (Y) meters long where X and Y are integers. Imagine that the land is divided into a X*Y number of square cells and every night she sows a magic seed in each cell. There is a 50% probability of a magic seed growing into a flower the next morning.

There is a school next to her farm land and in the morning a fixed number (S) of students visit her farm land to collect flowers. Jenny has to make sure that each student gets an equal number of flowers each day. To do that she draws (H) number of horizontal lines and (V) number of vertical lines on her farm land in such a way that the lines passes through the borders of the cells and does not cut them. This creates a rectangular grid and each student is instructed to collect flowers from a single grid. Here, the number of students (S) = (H+1)*(V+1).
Due to the uncertain nature of the magic seeds growing into a flower, sometimes Jenny is not able to distribute flowers equally through the grids created by horizontal and vertical lines.

Write a program to determine if Jenny would be able to equally distribute the flowers.

Input
Multiple line input where line one is the value of H, line two is the value of V and the remaining lines collectively show the farm land (which is (X) meters wide and (Y) meters long) with the presence or absence of a flower in each cell. Note: ‘ ’ indicates seeds have grown in to a flower and ‘.’ indicates absence of a flower in the cell. Number of students (S) = (H+1) (V+1). Refer case 1, 2 and 3 from the image.

Output
“TRUE” or “FALSE” in UPPER CASE.
Limits: Time limit is 10 seconds per test case and memory limit is 128MB.

SAP Labs OA

Coding question 1:- Find the count of prime numbers between l and r where 1 <= l, r <= 10 ^ 9 and those numbers whose digits are not even numbers and digits are less than 5
Eg :- l = 1
r = 10
Ans 1 i.e. (3)