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. :|”.


Input Output
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. :(



77% Solution Ratio

sahedsohelEarliest, Oct '17

s_dasailorFastest, 6225.8s

sahedsohelLightest, 1.0 MB

masum_iceShortest, 873B


Login to submit

Related Contests

18th IUT Computer Programming Contest 2017 Ended at 2017-10-04 12:20:00 +0000 UTC
Replay of 18th IUT Computer Programming Contest 2017 Ended at 2017-10-11 16:00:00 +0000 UTC