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
|
||||||||
2017-03-20 08:17:25
Easy! |
||||||||
2017-01-18 16:32:04
beginner prblm... jst a formula |
||||||||
2016-10-03 21:38:48
easy one beginner should try it ... |
||||||||
2016-06-29 14:11:50
easy formula :) |
||||||||
2016-06-13 13:45:21
ppl are using dp XP its simple formulae |
||||||||
2016-04-19 13:50:19
nice problem for beginners |
||||||||
2016-03-26 19:15:56
Solved Using Dp :) |
||||||||
2015-09-16 21:19:29
Hell Easy ^_^ |
||||||||
2015-09-06 00:34:55
AC in one go :-) take few minutes and find the pattern... it will b super easy problem.. njoyed while making recurense.. |
||||||||
2015-07-14 10:02:03 Sunil Kumar Samal
Try to solve it using recursion . |