Submit | All submissions | Best solutions | Back to list |
HS08SBAN - Broken Soroban |
"Here is a Japanese abacus which you can use for calculations in the decimal system. Successive digits in the decimal system are represented by successive columns of the abacus, starting from the right. In the upper row one bead has a value of 5, in each of the lower rows - a value of 1. You have some number of beads and your task is to allocate them between lower rows (max. four beads in one column) in order to maximize the number of values that can be represented on the abacus. You may assume, that there are all beads in the upper row."
Help Johnny find a solution to his problem!
Input
Every data set consists of two positive integers r s given in one row, where 1 <= r <= 8 represents the number of columns in abacus and 0 <= s <= 4 * r is the number of beads that Johnny has to distribute between columns in the lower rows.
Output
Write to output the maximum number of correct values that can be represented on such broken Soroban.
Example 1
Input: 2 1 Output: 8
Example 2
Input: 2 3 Output: 24
Scoring
For every test data you can get 2 points, summing to a total of 10 points.
Added by: | mima |
Date: | 2008-10-23 |
Time limit: | 0.200s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | ADA95 ASM32 BASH BF C CSHARP CPP C99 CLPS LISP sbcl LISP clisp D FORTRAN HASK ICON ICK JAVA LUA NEM NICE OCAML PAS-GPC PAS-FPC PERL PHP PIKE PRLG-swi PYTHON RUBY SCM guile SCM qobi ST WHITESPACE |
Resource: | High School Programming League 2008/2009 |