CF189B.Counting Rhombi

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You have two positive integers w and h. Your task is to count the number of rhombi which have the following properties:

  • Have positive area.
  • With vertices at integer points.
  • All vertices of the rhombi are located inside or on the border of the rectangle with vertices at points (0, 0), (w, 0), (w, h), (0, h). In other words, for all vertices (x__i, y__i) of the rhombus the following conditions should fulfill: 0 ≤ x__i ≤ w and 0 ≤ y__i ≤ h.
  • Its diagonals are parallel to the axis.

Count the number of such rhombi.

Let us remind you that a rhombus is a quadrilateral whose four sides all have the same length.

你有两个正整数 ww 和 hh。你的任务是计算满足以下条件的菱形的个数:

  • 面积为正;
  • 所有顶点均为整数点;
  • 菱形的所有顶点均位于或落在以点 (0, 0)(0,\,0)、(w, 0)(w,\,0)、(w, h)(w,\,h)、(0, h)(0,\,h) 为顶点的矩形内部或边界上。换言之,对菱形的每个顶点 (xi, yi)(x_i,\,y_i),均需满足:0 ≤ xi ≤ w0\,\le\,x_i\,\le\,w 且 0 ≤ yi ≤ h0\,\le\,y_i\,\le\,h;
  • 其两条对角线均与坐标轴平行。

请计算满足上述条件的菱形的个数。

需要提醒的是:菱形是指四条边长度均相等的四边形。

输入格式

The first line contains two integers w and h (1 ≤ w, h ≤ 4000) — the rectangle's sizes.

第一行包含两个整数 ww 和 hh(1 ≤ w, h ≤ 40001 \le w, h \le 4000)——矩形的尺寸。

输出格式

Print a single number — the number of sought rhombi.

Please do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.

输出一个整数——所求菱形的个数。

在 C++ 中,请勿使用 %lld 说明符读取或写入 64 位整数。推荐使用 cin、cout 流,或 %I64d 说明符。

输入输出样例

  • 输入#1

    2 2

    输出#1

    1
  • 输入#2

    1 2

    输出#2

    0

说明/提示

In the first example there exists only one such rhombus. Its vertices are located at points (1, 0), (2, 1), (1, 2), (0, 1).

在第一个示例中,仅存在一个这样的菱形。其顶点位于点 (1, 0)(1,\,0)、(2, 1)(2,\,1)、(1, 2)(1,\,2)、(0, 1)(0,\,1) 处。

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

首页