CF1725A.Accumulation of Dominoes
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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×M from left to right.
- Row 3 contains integers from 2×M+1 to 3×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≤N,M≤109 ) — 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.
The picture below is an example of a tight domino in the grid.