AtCoder Regular Contest 139
C
One Three Nine
AtCoder
⌀ 2406
原题
← BD →
翻译中…

Problem Statement

翻译中…

You are given positive integers $N$ and $M$.

翻译中…

Let us call a sequence of pairs of integers $((X_1,Y_1),(X_2,Y_2),\dots,(X_K,Y_K))$ wonderful when it satisfies the following.

翻译中…
  • $1 \le X_i \le N$
  • $1 \le Y_i \le M$
  • $X_i+3Y_i \neq X_j+3Y_j$ and $3X_i+Y_i \neq 3X_j+Y_j$, if $i \neq j$.
翻译中…

Make a wonderful sequence of pairs of integers whose length, $K$, is the maximum possible.

翻译中…

Constraints

翻译中…
  • $1 \le N,M \le 10^5$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N M

翻译中…

Output

翻译中…

Print your answer in the following format:

翻译中…

K
X_1 Y_1
X_2 Y_2
\vdots
X_K Y_K

翻译中…

Here, $K$ should be the maximum possible length of a wonderful sequence of pairs of integers, and $((X_1,Y_1),(X_2,Y_2),\dots,(X_K,Y_K))$ should be a wonderful sequence of pairs of integers. If multiple solutions exist, printing any of them is accepted.

翻译中…

样例

Input #1
3 4
Output #1
10
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
3 4
For $N=3, M=4$, there is no wonderful sequence of pairs of integers whose length is $11$ or longer, and the above sequence of pairs of integers is wonderful, so this output is valid.
题目信息
题号
arc139_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。