zoukankan      html  css  js  c++  java
  • Flea

    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 != 0)) * ((n - 1) % s + 1);
        y = (m / s + (m % s != 0)) * ((m - 1) % s + 1);
        cout<<x * y;
    }
  • 相关阅读:
    微信公众平台开发最佳实践
    微信公众平台运营规范
    微信智能开放平台
    微信公众平台模版消息
    Ace
    ZigBee介绍
    基于微信控制的智能家居产品
    微信商业模式的挑战点
    微信公众平台开发接口PHP SDK完整版
    微信公众平台开发(84) 小i机器人
  • 原文地址:https://www.cnblogs.com/8023spz/p/8434969.html
Copyright © 2011-2022 走看看