Submit | All submissions | Best solutions | Back to list |
BOMARBLE - D - Playing with Marbles |
PROBLEM D
PLAYING WITH MARBLES
Pablo was assigned in his class to construct pentagons inside pentagons with marbles but he doesn’t know how many marbles he will need. He knows that for one pentagon he needs 5 marbles
The only way he knows to insert a second pentagon is putting a marble in the middle of each segment and drawing three lines as shown. He puts a marble in the intersecting lines and removes them. To insert a third pentagon inside he first divides all segments in two including the ones that are not needed, and repeats the procedure. Drawing a second pentagon will require 12 marbles. A third pentagon will require 22 marbles. Given the information of how many pentagons will be created, write a program to calculate the number of marbles needed.
Input
The input contains several test cases. Each test case contains one integer N indicating the number of pentagons to create (1<=N<=103). The end of input is indicated by a line containing only one zero.
Output
For each test case in the input, your program must print a single line, containing one single integer, the number of marbles required.
Sample Input 1 2 3 0 Sample Output 5 12 22
Added by: | Alvaro Javier Medina Balboa |
Date: | 2010-05-25 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | C C++ 4.3.2 CPP JAVA |
hide comments
|
||||||||
2010-08-12 05:48:30 Ruslan Sennov
Needed figure can be found here: https://www.spoj.pl/UMSA4/UMSA4/content/SetProblemas.pdf |
||||||||
2010-08-01 16:46:00 :D
I'm thankfull to Alvaro for posting problems, but this desription is very unclear. Comment from Ravi Kiran should be enough for you to understand the line drawing procedure. The segment means an edge of any previously drawn pentagon. After setting up every pentagon, you remove marbles not being a vertex of any pentagon. You can't reuse previously put marbles and every pentagon must stay outlined. Hope that clears things up. |
||||||||
2010-07-08 14:21:42 pantop
@ravi plz tell how did we get 22 marbles fr 3 pentagons... As per my calculations- 5 fr 1, 12 fr 2 then he will put 5 marbles in the mid of five sides of the small pentagon, draws lines and put 2 more..so (12+7) for 3 pentagons... plz tell me how did U get 22... |
||||||||
2010-06-20 20:17:36 Oleg
Thanks :) |
||||||||
2010-06-20 08:17:45 Ravi Kiran
Imagine the pentagons to be sharing the top vertex and having base parallel to the parent's base. Hope that can help a little! :) |
||||||||
2010-06-14 10:01:53 Oleg
Maybe to rename problem to "guess the image" :) please hint where these 3 lines should be drawn. |
||||||||
2010-06-10 01:13:54 Anton Lunyov
with some intuition this problem can be solved without image. :) |