Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Tiles Creator

By jackal_1586 · Limits 1s, 512 MB

In the world of tiles, there is a famous tiles maker who takes order for making tiles. The specialty about him is that he always creates square tiles and likes to cover up the given area using minimum number of tiles.


The input line contains two positive integers, m and n (0 ≤ m, n ≤ 10000), indicating the length and width of the area to cover with tiles. Your program should run until the end of file.


For each input line, you have to find out the minimum number of square tiles to cover up the entire area.

Remember the tiles provider gets very happy when a prime number of tiles are used and gets unhappy otherwise. So, print a smiley ":)" in case of prime or ":(" for otherwise, after a space while printing the last line of a test case. In case, no tiles can be fitted in the area print “Area cannot be covered. :|”.


3 1
13 29
10 10
2 8
1 x 1 tiles required 3
In total minimum 3 tiles required. :)
13 x 13 tiles required 2
3 x 3 tiles required 4
1 x 1 tiles required 3
In total minimum 9 tiles required. :(
10 x 10 tiles required 1
In total minimum 1 tile required. :(
2 x 2 tiles required 4
In total minimum 4 tiles required. :(



78% Solution Ratio

sahedsohelEarliest, Oct '17

Being_GoromFastest, 0.0s

sahedsohelLightest, 1.0 MB

bokaifShortest, 429B


Login to submit

Toph uses cookies. By continuing you agree to our Cookie Policy.