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. windows安装mysql教程2017最新

    1.首先在mysql官网下载最新版mysql, 附上链接点击打开链接,根据你的系统型号选择对应的包下载,大约300多兆,版本号为5.7.19 下载完之后,解压缩,是一个标准的mysql文件 2.第二步 ...

  2. vue 项目结构说明

    eslink:规范es6的代码风格检测工具. npm install node-sass -g :全局安装,即使安装之后可以全局使用dode-sass,不用进到工具目录. .babel:把es6转换成 ...

  3. 玩转python主题模型程序库gensim

    gensim是python下一个极易上手的主题模型程序库(topic model),网址在:http://radimrehurek.com/gensim/index.html 安装过程较为繁琐,参考h ...

  4. iMX6 yocto平台QT交叉编译环境搭建

    转:https://blog.csdn.net/morixinguan/article/details/79351909 . /opt/fsl-imx-fb/4.9.11-1.0.0/environm ...

  5. [POI2008]砖块Klo

    题目 爆炸\(OJ\)机子太慢了吧实在不想打平衡树了 做法 烂大街的一个概念:求中位数 然后求前缀差和后缀差,主席树模板题 注意\(int\)和\(long long\) My complete co ...

  6. 20145231《Java程序设计》第三次实验报告

    实验三 敏捷开发与XP实现 实验内容 XP基础 XP核心实践 相关工具 实验要求 了解敏捷开发的基本方法以及XP软件开发的相关准则:了解代码编写的标准和原则:体会结对编程的好处: 实践体会版本控制的方 ...

  7. winter 2018 02 01 关于模运算的一道题

    题目:给出一个正整数n,问是否存在x,满足条件2^x mod n=1,如果存在,求出x的最小值. 分析:1.若给出的n是1,则肯定不存在这样的x;     2.若给出的是偶数,2的次幂取余一个偶数得到 ...

  8. PostgresSQL数据库安装及操作

    PostgreSQL介绍 PostgreSQL是一个功能强大的开源对象关系数据库管理系统(ORDBMS). 用于安全地存储数据; 支持最佳做法,并允许在处理请求时检索它们. PostgreSQL(也称 ...

  9. iOS上架被拒原因及解决办法

    简单的记录一下,近期APP上架所遇到的坑爹事儿吧!! 第一次提交: 第二天给了回复,内容如下: .Guideline - Performance - Software Requirements You ...

  10. SwfUpload文件上传

    SWFUpload是一个flash和js相结合而成的文件上传插件,其功能非常强大.以前在项目中用过几次,但它的配置参数太多了,用过后就忘记怎么用了,到以后要用时又得到官网上看它的文档,真是太烦了.所以 ...