#B3697. Carpet Tiling Problem

    ID: 11356 Type: Default 1000ms 256MiB

Carpet Tiling Problem

Carpet Tiling Problem

Given a rectangle with length \(a\) meters and width \(b\) meters and a square carpet with side length \(c\) meters, determine if the entire rectangle can be exactly tiled with these carpets without cutting any carpet and without any overlaps. If tiling is possible, output the number of carpets required; otherwise, output -1.

inputFormat

The input consists of three positive integers \(a\), \(b\), and \(c\) separated by spaces.

outputFormat

Output a single integer representing the number of carpets needed to tile the rectangle completely, or -1 if it is not possible.

sample

8 6 2
12