fork(8) download
  1. ##############################################
  2. ### http://w...content-available-to-author-only...f.com/problems/COINS ###
  3. ##############################################
  4. conv = {0:0}
  5.  
  6. def exch(num):
  7. if num in conv:
  8. return conv[num]
  9. else:
  10. conv[num] = max(num, exch(num/4)+exch(num/3)+exch(num/2))
  11. return conv[num]
  12. while True:
  13. try:
  14. print exch(int(raw_input()))
  15. except:
  16. break
Success #stdin #stdout 0.01s 7732KB
stdin
1000000000
30
27
26
25
24
12
2
stdout
4243218150
32
28
27
27
27
13
2