【topcoder】Kodifica – Pratice Round 1




You need to update the balance in your checkbook. You know your starting balance, the total amount spent using your debit card, and the total value of checks that have been written. Return your ending balance.



Preparing a national budget involves sums of large numbers. These numbers should be formatted in a nice way. Your task is, given some nicely formatted costs (in US dollars and cents), add up the costs and return the nicely formatted total cost.  The nice format is: Numbers are decimal (base ten). Always display the cents as two digits to the right of the decimal point, even if this gives trailing zeros. Always display at least one digit to the left of the decimal point. Unless the absolute value of the number is less than one dollar, use no leading zeros. If the absolute value of the number is less than one dollar there should be one zero to the left of the decimal point. If the number of digits to the left of the decimal point is five or more, then insert commas between groups of three digits from right to left from the decimal point. (see examples) If the number is positive (greater than or equal to zero) the first character is “$”. If the number is negative (strictly less than zero) then the first two characters are “-$”.


改了竟然 没 地 方 交 !!!

Cat Taro likes lucky strings. The digits 4 and 7 are considered lucky. A lucky string is a string such that each of its characters is a lucky digit (i.e., either ‘4’ or ‘7’). Consider some lucky string S. In one turn Taro can swap any two (not necessarily consecutive) characters of that string. He considers the string S very lucky if its characters can be sorted into non-decreasing order using at most K turns. You are given two ints N and K. Let X be the number of different very lucky strings of length N. Return the value (X modulo 1,000,000,007).



  1. Pingback: 水泥板