找到这样的起始位置(x,y)的数量,其具有最大可能值dx,y [英] find the number of such starting position(x,y), which have the maximum possible value of dx,y

查看:49
本文介绍了找到这样的起始位置(x,y)的数量,其具有最大可能值dx,y的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

热带森林中有一只蚱蜢。蚱蜢只能垂直和水平跳跃,跳跃的长度总是等于x厘米。一个GRasshopper发现自己处于棋盘的某个单元格的中心,大小为pxq厘米(每个单元格为1x1厘米)。她可以随心所欲地跳跃,她甚至可以不止一次地去看一个牢房。唯一的限制是她不能跳出董事会。



蚱蜢可以计算从起始位置(x,y)可以到达的单元格数量。我们用dx,y表示这个数量。你的任务是找到这样的起始位置(x,y)的数量,其最大可能值为dx,y



输入



整数数组包含三个整数p,q,x



p =董事会的长度

q =板的宽度



x =蚱蜢跳的长度。



输出



输出唯一的整数 - GRasshopper所需的起始位置的数量



例子



输入2 3 1000000

输出6



输入3 3 2

输出4

There is a Grasshopper in a tropical forest. The grasshopper can jump only vertically and horizontally, and the length of jump is always equal to x centimeter. A GRasshopper has found herself at the center of some cell of the chess board of the size pxq centimeters(each cell is 1x1 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 grasshopper can count the number 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 position(x,y), which have the maximum possible value of dx,y

Input

The integer array contains three integers p,q,x

p= length of the board
q= width of the board

x=length of the grasshoppers jump.

Output

Output the only integer - the number of the required starting position of the GRasshopper

Example

input 2 3 1000000
output 6

input 3 3 2
output 4

推荐答案

public static int squareCount(int[] input1)
        {
            int return_result;
            if (((input1[0] - 0.5) >= input1[2]) && ((input1[1] - 0.5) >= input1[2]))
            {
                return_result = 4;
            }
            else if ((((input1[0] - 0.5) >= input1[2]) && ((input1[1] - 0.5) < input1[2])) || (((input1[0] - 0.5) < input1[2]) && ((input1[1] - 0.5) >= input1[2])))
            {
                return_result = 2;
            }
            else
            {
                return_result = input1[0] * input1[1];
            }
            return return_result;
        }


这篇关于找到这样的起始位置(x,y)的数量,其具有最大可能值dx,y的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆