QOJ.ac

QOJ

时间限制: 1 s 内存限制: 1024 MB 总分: 100 可 Hack ✓

#17922. 巧克力金字塔

统计

Coco 有无限多个形状独特的白巧克力和黑巧克力。白巧克力是每个棱长均为 $1$ 的四棱锥,黑巧克力是每个棱长均为 $1$ 的正四面体。有一天,Coco 在玩这些巧克力时发现,如果把它们堆叠得当,就可以拼出一个更大的四棱锥。搭建底面矩形大小为 $R \times C$ 的金字塔的具体方法如下:

  1. 首先,用 $R \times C$ 个白巧克力铺满底面。
  2. 在白巧克力之间的空隙中填满黑巧克力。
  3. 在黑巧克力之间的空隙中再次填满白巧克力。进行到这一步时,顶面会变成一个大小为 $(R-1) \times (C-1)$ 的平整矩形。
  4. 重复上述步骤,直到顶面的面积变为 $0$。

下图展示了搭建 $2 \times 3$ 金字塔第 1 层的过程。搭建第 1 层需要 8 个白巧克力和 7 个黑巧克力,如果加上第 2 层,则总共分别需要 10 个和 8 个。

Coco 想要制作一个非常大的巧克力金字塔送给 Hanbyul。请帮他计算一下,分别需要多少个白巧克力和黑巧克力。

输入格式

第一行包含测试用例的数量 $T$。接下来的 $T$ 行中,每行按顺序给出整数 $R$ 和 $C$。

输出格式

对于每个测试用例,在一行中按顺序输出所需的白巧克力数量和黑巧克力数量。

样例

输入样例 1

2
2 3
10 10

输出样例 1

10 8
670 660

说明

$1 \le T \le 10^5$,$1 \le R, C \le 10^6$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.