编程介的小学生 2017-09-06 02:28 采纳率: 20.5%
浏览 867
已采纳

Bean Counting

The CSC has decided to hold a contest to guess the number of beans in a given jar. To make it a wee bit more interesting, they decided to have the contestants guess the number of a particular kind of bean, the jar having many types of beans in it. Each participant would par $2.00 per guess.
If the guess is one off (either one greater or less) than the actual count, they get a single share of the total pot. If the guess is right on, they get two shares of the total pot.

Your task is to tally these guesses and print out how much each person wins.

Input

The first line will contain hundreds of letters, from a - z, each representing one bean of that type of bean. There will only be 26 different types of beans. The next line contains an integer n, the number of guesses. Each of the n following line will be the guess from a contestant. A contestant can guess as many times as they like. The line will begin with a single letter, in the range A - Z, leaving only 26 possible contests. The first letter will be followed by a single space, and then up to five pairs of letter/number combinations, the letter representing the type of bean for this guess, and the number the number of that bean the contestant expects to find. The letter and the value of a guess will be separated by a ':' and each guess on lines with more than one guess will be separated by a ','.

Process to the end of file.

Tallying:

The amount a contestant will receive is based on shares of a pot. The pot will consist of the total of all the guesses, at $2.00 per guess. The fraction each person gets will be based on:

TotNum: total number of guesses by all contestants
TotShares: total number of shares from all contestants
OffOne: number of off-by-one guesses by that contestant
RightOn: number if right-on guesses by that contestant

(TotNum * $2.00) / TotShares * (OffOne + (RightOn * 2))

Output

Print out all the winners, in alphabetical order, and their winnings, separated by a single space. Each winner should be on a line by itself.

Separate output for different cases by a single blank line.

Sample Input

aadddddddddddddddddddddddffffffffffffffffwwwwwwwwwwwwccccalalala
4
A a:6,c:6
B w:12
C d:25
D d:22,c:4,l:3,f:15

Sample Output

A 3.20
B 3.20
D 9.60

  • 写回答

1条回答

  • threenewbee 2017-09-20 15:43
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?