Vital Jays

Greenhorn

Posts: 27

posted 8 months ago

Positive integers A, B, C are given. The maximum possible number of squares with side C (without overlays) is placed on the rectangle of size A × B. The task is to find the number of squares placed on the rectangle, as well as the area of the unoccupied part of the rectangle.

My try is following:

n is number of squares and side c is the side of square here. Would you help me to find s here.

Thank you in advance.

My try is following:

n is number of squares and side c is the side of square here. Would you help me to find s here.

Thank you in advance.

Tony Docherty

Bartender

Posts: 3271

82

posted 8 months ago

Your question isn't related to Java it's about the algorithm so this isn't really the place to post such a question.

Having said that your first problem is to find 'n', so I'd make sure that is correct before moving on to finding s. If your rectangle is 5 x 3 and the size of your squares are 1 then how many squares fit into the rectangle. BTW the way it isn't 3.

you should really work this out in your head (or get some paper and cut out some squares and try fitting them into a rectangle) before running your code to check the code is producing the correct answer.

Having said that your first problem is to find 'n', so I'd make sure that is correct before moving on to finding s. If your rectangle is 5 x 3 and the size of your squares are 1 then how many squares fit into the rectangle. BTW the way it isn't 3.

you should really work this out in your head (or get some paper and cut out some squares and try fitting them into a rectangle) before running your code to check the code is producing the correct answer.

Piet Souris

Master Rancher

Posts: 2044

75

Vital Jays

Greenhorn

Posts: 27

Piet Souris

Master Rancher

Posts: 2044

75

Vital Jays

Greenhorn

Posts: 27