309716: CF1725A. Accumulation of Dominoes

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Accumulation of Dominoes

题意翻译

## 题目描述 给定一个 $N$ 行 $M$ 列的矩阵,数字从 $1$ 开始,从左到右,从上到下依次在矩阵内排列。 定义 domino 为矩阵内相邻的两个差为 $1$ 的数,求一共有多少个不同的 domino。 两个 domino 不同当且仅当第一个 domino 其中的至少一个数在第二个 domino 没有出现。 ## 输入格式 一行两个整数 $N$ 和 $M$ ( $ 1 \leq N, M \leq 10^9 $ ) ,表示矩阵共有 $N$ 行 $M$ 列。 ## 输出格式 一个整数,表示一共有多少个不同的 domino。

题目描述

Pak Chanek has a grid that has $ N $ rows and $ M $ columns. Each row is numbered from $ 1 $ to $ N $ from top to bottom. Each column is numbered from $ 1 $ to $ M $ from left to right. Each tile in the grid contains a number. The numbers are arranged as follows: - Row $ 1 $ contains integers from $ 1 $ to $ M $ from left to right. - Row $ 2 $ contains integers from $ M+1 $ to $ 2 \times M $ from left to right. - Row $ 3 $ contains integers from $ 2 \times M+1 $ to $ 3 \times M $ from left to right. - And so on until row $ N $ . A domino is defined as two different tiles in the grid that touch by their sides. A domino is said to be tight if and only if the two numbers in the domino have a difference of exactly $ 1 $ . Count the number of distinct tight dominoes in the grid. Two dominoes are said to be distinct if and only if there exists at least one tile that is in one domino, but not in the other.

输入输出格式

输入格式


The only line contains two integers $ N $ and $ M $ ( $ 1 \leq N, M \leq 10^9 $ ) — the number of rows and columns in the grid.

输出格式


An integer representing the number of distinct tight dominoes in the grid.

输入输出样例

输入样例 #1

3 4

输出样例 #1

9

输入样例 #2

2 1

输出样例 #2

1

说明

The picture below is the grid that Pak Chanek has in the first example. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1725A/6ffa3c95ba2e7eb37086c5fb9dfc34c4a6f85917.png)The picture below is an example of a tight domino in the grid. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1725A/783449c7a56f95aae2e8417723a42d88940b07e9.png)

Input

题意翻译

## 题目描述 给定一个 $N$ 行 $M$ 列的矩阵,数字从 $1$ 开始,从左到右,从上到下依次在矩阵内排列。 定义 domino 为矩阵内相邻的两个差为 $1$ 的数,求一共有多少个不同的 domino。 两个 domino 不同当且仅当第一个 domino 其中的至少一个数在第二个 domino 没有出现。 ## 输入格式 一行两个整数 $N$ 和 $M$ ( $ 1 \leq N, M \leq 10^9 $ ) ,表示矩阵共有 $N$ 行 $M$ 列。 ## 输出格式 一个整数,表示一共有多少个不同的 domino。

Output

题目大意:给定一个N行M列的矩阵,矩阵中的数字从1开始,从左到右,从上到下依次排列。定义domino为矩阵内相邻的两个差为1的数,求一共有多少个不同的domino。两个domino不同当且仅当第一个domino其中的至少一个数在第二个domino没有出现。

输入输出数据格式:

输入格式:一行两个整数N和M(1≤N,M≤10^9),表示矩阵共有N行M列。

输出格式:一个整数,表示一共有多少个不同的domino。题目大意:给定一个N行M列的矩阵,矩阵中的数字从1开始,从左到右,从上到下依次排列。定义domino为矩阵内相邻的两个差为1的数,求一共有多少个不同的domino。两个domino不同当且仅当第一个domino其中的至少一个数在第二个domino没有出现。 输入输出数据格式: 输入格式:一行两个整数N和M(1≤N,M≤10^9),表示矩阵共有N行M列。 输出格式:一个整数,表示一共有多少个不同的domino。

加入题单

上一题 下一题 算法标签: