P27813 [洛谷] [Language Competition 202301] Carpet Laying
普及-
题目描述

Problem Background

To prepare for a unique award ceremony, organizers are laying some square carpets over a rectangular area in the venue.

Problem Description

The rectangular area is $a$ meters long and $b$ meters wide. The carpets are square with a side length of $c$ meters.

The organizer wants to know whether it is possible to cover the entire rectangle with several of these carpets without cutting them and ensuring they do not overlap. If it is possible, how many carpets are needed to cover the entire rectangle.

Input Format

The input consists of a single line with three positive integers $a, b, c$, representing the length and width of the rectangular area and the side length of the carpet, respectively.

Output Format

The output consists of a single line.

If it is not possible to cover the entire rectangle with several of these carpets, output -1.

If it is possible to cover the entire rectangle with several of these carpets, output a single positive integer representing the number of carpets needed.

Sample Input and Output

Sample Input #1

20 15 5

Sample Output #1

12

Sample Input #2

39 17 24

Sample Output #2

-1

Notes

Sample 1 Explanation

By placing 12 carpets in the following manner, the entire rectangle can be covered.

Image

Sample 2 Explanation

It is easy to see that there is no way to cover the entire rectangle with several of these carpets.

Data Range and Constraints

For all test cases: $1 \leq a, b \leq 10^{18}$, $1 \leq c \leq 10^{18}$. If an answer exists, the final answer will not exceed $10^{18}$.

Test Case $a, b$ $c$ Special Properties
1, 2 $\leq 10^3$ $\leq 10^3$ None
3, 4 $\leq 10^{18}$ $= 1$ None
5 $\leq 10^{18}$ $\leq 10^{18}$ Guaranteed $a, b < c$
6 to 10 $\leq 10^{18}$ $\leq 10^{18}$ None
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
20 15 5
样例输出
12