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<=10^{3}). 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
hide comments
ashutoshkumar6:
20181023 20:03:51
ac in one go.....just observe the pattern of position of marble and try to find out a formula 

shivamyadav00:
20181021 14:04:08
thank you @DreamBig....for more test cases. 

shashankpathak:
20180914 23:01:39
Easy find Ap pattern!! 

pratapvidhu_17:
20180113 15:08:17
why this formula (a=(5*n+((n*n+n)/2)+(pow(2,n1))3) (n>1)is not accepted :/ ?? as it gives same value as formula for accepted one....


sandilya1599:
20180111 17:36:05
Easy! 

v_pp_27:
20171108 19:24:42
100 th....! 

epsilonalpha:
20170612 12:03:44
AC in one go. Easy recurrence. :) 

sagnik_66:
20170606 09:27:47
Solved using both formula and dp :) 

ajeetk_973:
20170402 05:19:37
hell easy with recursiondp just formula 

nilabja16180:
20170320 08:17:25
Easy! 
Added by:  Alvaro Javier Medina Balboa 
Date:  20100525 
Time limit:  0.140s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  C C++ 4.3.2 CPP JAVA 