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
hide comments
nadstratosfer:
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. |
|
hodobox:
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. |
|
Piyush Kumar:
2015-05-31 11:37:08
Test Cases do not have k>10^5 |
|
Tarun Dutt:
2014-12-19 10:38:56
Nice question :)
|
|
Bhavik:
2013-12-15 13:42:51
just solve for level 3 nd u are good to go:)
|
|
Bhavik:
2013-12-14 19:44:38
for level 3 is no of pyramids=19??
|
|
Martijn Muijsers:
2013-10-23 23:38:03
0.05, damn I can not beat you guys :P
|
|
Hamim Raavi:
2013-07-16 15:58:44
nice problem...AC with 0.04s and 241B :) |
|
(Tjandra Satria Gunawan)(曾毅昆):
2013-05-25 15:29:27
@Lakshman: Wow! your running time is awesome ~2x faster than my code with full opti that I know.. Or test data has been changed(?)
|
|
[Lakshman]:
2013-05-15 18:02:12
Finally AC using java with 498B.....
|
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 |