CF32C.Flea

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

It is known that fleas in Berland can jump only vertically and horizontally, and the length of the jump is always equal to s centimeters. A flea has found herself at the center of some cell of the checked board of the size n × m centimeters (each cell is 1 × 1 centimeters). She can jump as she wishes for an arbitrary number of times, she can even visit a cell more than once. The only restriction is that she cannot jump out of the board.

The flea can count the amount of cells that she can reach from the starting position (x, y). Let's denote this amount by d__x, y. Your task is to find the number of such starting positions (x, y), which have the maximum possible value of d__x, y.

已知伯兰的跳蚤只能垂直或水平跳跃,且每次跳跃的长度恒为 ss 厘米。一只跳蚤发现自己位于一块 n×mn \times m 厘米的方格棋盘(每个格子为 1×11 \times 1 厘米)中某个格子的中心。她可以任意次数地跳跃,甚至可以多次访问同一格子。唯一的限制是她不能跳出棋盘边界。

跳蚤能够计算出从起始位置 (x,y)(x, y) 出发所能到达的格子总数,记该数为 dx,yd_{x,y}。你的任务是:找出所有使得 dx,yd_{x,y} 取得最大可能值的起始位置 (x,y)(x, y) 的个数。

输入格式

The first line contains three integers n, m, s (1 ≤ n, m, s ≤ 106) — length of the board, width of the board and length of the flea's jump.

第一行包含三个整数 nn、mm、ss(1 ≤ n, m, s ≤ 1061 ≤ n, m, s ≤ 10^6)—— 分别表示棋盘的长度、宽度以及跳蚤的跳跃长度。

输出格式

Output the only integer — the number of the required starting positions of the flea.

输出唯一的整数——跳蚤所需起始位置的数量。

输入输出样例

  • 输入#1

    2 3 1000000

    输出#1

    6
  • 输入#2

    3 3 2

    输出#2

    4

输入解题思路,AI测评打分。不知道怎么写?

首页