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 dx, y. Your task is to find the number of such starting positions (x, y), which have the maximum possible value of dx, y.

Input

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.

Output

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

Example

Input
2 3 1000000
Output
6
Input
3 3 2
Output
4

其实就是从最角上一个点看看最多能跳到几个点,然后这些点形成一个矩形,在n*m的框框里存在几个这样的矩形,最后相乘就好了。
代码:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath> using namespace std;
long long n,m,s,x,y;
int main()
{
scanf("%lld%lld%lld",&n,&m,&s);
x = (n / s + (n % s != )) * ((n - ) % s + );
y = (m / s + (m % s != )) * ((m - ) % s + );
cout<<x * y;
}

Flea的更多相关文章

  1. Codeforces Beta Round #51 A. Flea travel 水题

    A. Flea travel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/problem ...

  2. CodeForces 32C. Flea 水题

    C. Flea time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...

  3. UVA 10620 - A Flea on a Chessboard(鸽笼原理)

    UVA 10620 - A Flea on a Chessboard 题目链接 题意:给定一个跳蚤位置和移动方向.如今在一个国际象棋棋盘上,左下角为黑格,一个格子为s*s,推断是否能移动到白格子.问要 ...

  4. 未来-YLB-跳蚤市场:跳蚤市场(flea market)

    ylbtech-未来-YLB-跳蚤市场:跳蚤市场(flea market) 跳蚤市场(flea market)是欧美等西方国家对旧货地摊市场的别称.由一个个地摊摊位组成,市场规模大小不等. 出售商品多 ...

  5. Flea Circus(Project Euler 213)

    original version hackerrank programming version 题目大意是N*N的格子,每个格子一开始有1个跳蚤,每过单位时间跳蚤会等概率向四周跳,问M秒后空格子的期望 ...

  6. CodeForces 32C Flea

    题目链接:http://codeforces.com/problemset/problem/32/C 本文链接:http://www.cnblogs.com/Ash-ly/p/5513436.html ...

  7. 分布式系统理论基础 - 一致性、2PC和3PC

    引言 狭义的分布式系统指由网络连接的计算机系统,每个节点独立地承担计算或存储任务,节点间通过网络协同工作.广义的分布式系统是一个相对的概念,正如Leslie Lamport所说[1]: What is ...

  8. 机器学习实战笔记(Python实现)-03-朴素贝叶斯

    --------------------------------------------------------------------------------------- 本系列文章为<机器 ...

  9. 朴素贝叶斯算法的python实现

    朴素贝叶斯 算法优缺点 优点:在数据较少的情况下依然有效,可以处理多类别问题 缺点:对输入数据的准备方式敏感 适用数据类型:标称型数据 算法思想: 朴素贝叶斯比如我们想判断一个邮件是不是垃圾邮件,那么 ...

随机推荐

  1. Ajax+Spring MVC实现跨域请求(JSONP)

    背景: AJAX向后台(springmvc)发送请求,报错:已阻止交叉源请求:同源策略不允许读取 http://127.0.0.1:8080/DevInfoWeb/getJsonp 上的远程资源.可 ...

  2. Android开发之旅-Fragment和Activity之间onCreateOptionsMenu的联系

    Fragment和Activity一样,可以重写onCreateOptionsMenu方法来设定自己的菜单,其实这两个地方使用onCreateOptionsMenu的目的和效果都是完全一样的,但是由于 ...

  3. 【HackerRank】QuickSort(稳定快排,空间复杂度O(n))

    QuickSort In the previous challenge, you wrote a partition method to split an array into 2 sub-array ...

  4. STP生成树协议原理与算法解析

    转:https://wenku.baidu.com/view/2e52b91d866fb84ae45c8d34.html

  5. [C++] 麻将胡牌算法

    麻将的玩法规则众多,核心的玩法是一致的,本文将根据联发科2017年编程挑战赛的复赛题规则来实现. 牌的表示方式 ABCDEFGHI代表一到九萬,abcdefghi代表一到九条,123456789代表一 ...

  6. yum 源配置

    在 /etc/yum.repos.d 下建立一个 .repo 文件 vim  yum.repo [cd] name=cd baseurl=file:///run/media/root/RHEL-7.0 ...

  7. jsp中的basePath和path(绝对路径 相对路径)

    在JSP中的如果使用 "相对路径" 则有 可能会出现问题. 因为 网页中的 "相对路径" , 他是相对于 "URL请求的地址" 去寻找资源. ...

  8. LCN协调者服务集群

    官方文档: https://github.com/codingapi/tx-lcn/wiki/TxManager%E9%9B%86%E7%BE%A4%E8%AF%B4%E6%98%8E 核心原理 通过 ...

  9. Shell脚本报错--syntax error near unexpected token for((i=0;i<$length;i++))

    现象: shell脚本使用Nodepad++进行本地编辑,在编辑后上传到linux机器进行执行时提示“syntax error near unexpected token for((i=0;i< ...

  10. makefile下$(wildcard $^),$^,$@,$?,$<,$(@D),$(@F) 含义

    makefile下$(wildcard $^),$^,$@,$?,$<,$(@D),$(@F)代表的不同含义 $(filter-out $(PHONY) $(wildcard $^),$^) 常 ...