PIRACON - Pyramidal Constructions

Humberto is a great Egyptian architect. In Egypt pyramid sculptural constructions were as common as ornaments. Pharaoh has asked Humberto to build N pyramids throughout Egypt. Humberto is very stingy when it comes to construction costs, so he always buys the exact necessary number of materials needed to complete his work.

Tural Pyramids are built using smallest pyramids of "level 1", that are used as building blocks for higher levels. Stacking pyramids of "level 1" to create higher-level structures, leave gaps. Special parts, called "Tringus", are used to cover these gaps. They are of triangular shape, designed by Humberto to perfectly fill the gaps on piramid sides.

For example, a pyramid of "Level 2" is constructed as follows: We are using a total of 6 pyramids of "level 1" (see the picture above). That leaves 4 gaps at the sides and we need 4 "Tringus" fo fill them. In total 10 pieces.

Humberto asks us to help to calculate the total number and "Tringus" number of pieces needed for a pyramid of level K.

Input

First line contains integer T, number of test cases. Following N lines, each containing an integer K, the level of the piramid.

Output

You must print "Pyramid E. Nro# i: ", followed by the total number of parts used (both pyramids of "level 1" and "Tringus"). In the next line print "Tringus: ", followed by the number of "Tringus" used.

Example

Input:
2
1
4

Output:
Pyramid E. Nro# 1: 1
Tringus: 0
Pyramid E. Nro# 2: 68
Tringus: 24

Constraints

1<= T <= 10^4
1<= K <= 10^6


Added by:Raffaele Ranaldo
Date:2013-05-13
Time limit:0.100s
Source limit:500B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own Problem

hide comments
2019-06-24 02:25:17
Hodobox: The image shows how adding level 1 pieces to k=1 pyramid leads to construction of k=2 pyramid. If you can imagine constructing k=3 from there, following the same method using level 1 pieces, you get the recurrence relation that generates the sequence. You can reduce it to obtain the formula for nth level pyramid.
2019-05-25 04:55:03
The patterns can be found in OEIS, but I still have no idea how the pyramids are supposed to be built. The description explains how to build a level 2, but not a level X in general. The go-to explanation would be that it is recursive (we take 6 level 2 pyramids to build a level 3 in the same way as level 1 -> level 2), but this is obviously not the case given the answer for level 4.
2015-05-31 11:37:08 Piyush Kumar
Test Cases do not have k>10^5
2014-12-19 10:38:56 Tarun Dutt
Nice question :)
simple math.
2013-12-15 13:42:51 Bhavik
just solve for level 3 nd u are good to go:)
N,K are in float(read original prob statement)

Last edit: 2013-12-15 13:45:03
2013-12-14 19:44:38 Bhavik
for level 3 is no of pyramids=19??
plz tell me if i am thinking right...
2013-10-23 23:38:03 Martijn Muijsers
0.05, damn I can not beat you guys :P

Good problem, had me thinking for quite a while!
2013-07-16 15:58:44 Hamim Raavi
nice problem...AC with 0.04s and 241B :)
2013-05-25 15:29:27 (Tjandra Satria Gunawan)(曾毅昆)
@Lakshman: Wow! your running time is awesome ~2x faster than my code with full opti that I know.. Or test data has been changed(?)
@raffaele:
test cases are unchanged.

Last edit: 2013-05-20 20:35:38
2013-05-15 18:02:12 [Lakshman]
Finally AC using java with 498B.....

@Raffaele:
jaja good job men. xD

AC --.02 c++;

Last edit: 2013-05-15 18:54:26
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.