Chocolate Pyramid
Time limit1sMemory limit1024 MB
Given an R x C base, count the white and dark chocolates needed to build the full pyramid, layer by layer, until the top face is empty.
- Level
Medium5 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Coco has an unlimited number of white chocolates and dark chocolates with unusual shapes. A white chocolate is a square pyramid where every edge has length 1, and a dark chocolate is a regular tetrahedron where every edge has length 1. One day, while playing with these chocolates, Coco found that they can be stacked to build a larger square pyramid. The method for stacking a pyramid whose base is an rectangle is as follows.
- First, fill the base with white chocolates.
- Fill the gaps between the white chocolates with dark chocolates.
- Fill the spaces between the dark chocolates with white chocolates again. After this step, the top face is a flat rectangle.
- Repeat until the area of the top face is 0.
The figure below shows how the first layer of a pyramid is filled. Filling the first layer requires 8 white chocolates and 7 dark chocolates. Including the second layer, the totals are 10 white chocolates and 8 dark chocolates.

Coco wants to build a very large chocolate pyramid and give it to Hanbyeol as a gift. Calculate how many white chocolates and how many dark chocolates are needed.
Input
The first line contains the number of test cases . Each of the next lines contains two integers and , in that order.
Output
For each test case, print the number of white chocolates and the number of dark chocolates needed, in that order, on one line.