eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Counting Lattice Squares

Counting Lattice Squares

\includegraphics{https://static.e-olymp.com/content/c4/c48f2e8212ce76524121a3c03b63c0b964d301f5.jpg} A lattice square is a square whose vertices are all lattice points. A lattice-point is a point in Cartesian coordinate system whose abscissa and ordinate are integers. For example (\textbf{1, 5}) is a lattice point but (\textbf{1, 1.5}) is not. In a (\textbf{n}×\textbf{m}) grid there can be many lattice squares. In the figure on the left you can see some lattice squares in a (\textbf{4}×\textbf{4}) grid. Counting lattice squares with axis-parallel sides (Figure 1, Figure 2 and Figure 3) is trivial but there are lattice squares whose sides are not axis parallel (Figure 4, Figure 5 and Figure 6) and counting them is just a bit harder. Some of these squares can have even area (Figure 2, Figure 4, Figure 6) and some others can have odd area (Figure 1, Figure 3, Figure 5). Given an (\textbf{m}×\textbf{n}) grid your job is to write a program that counts how many different lattice squares with odd area can be drawn in that grid. Two lattice squares are different if they do not share all four vertices. \InputFile The input file contains at most \textbf{50000} lines of inputs. Each line contains two integers \textbf{m}, \textbf{n} (\textbf{1} ≤ \textbf{m}, \textbf{n} ≤ \textbf{100000}). Input is terminated by a line containing two zeroes. \OutputFile For each line of input produce one line of output. This line contains an integer \textbf{S}, which denotes how many different lattice squares with odd area can be drawn in an (\textbf{m}×\textbf{n}) grid. You can assume that the value of \textbf{S} fits in a \textbf{64}-bit signed integer.
Ліміт часу 5 секунд
Ліміт використання пам'яті 128 MiB
Вхідні дані #1
2 2
3 3
4 4
0 0
Вихідні дані #1
4
12
28
Автор Dr. Shahriar Manzoor
Джерело ACM-ICPC Asia Phuket Regional Programming Contest 2013, 22 November 2013