 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 offbyone guesses by that contestant
RightOn: number if righton 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:15Sample Output
A 3.20
B 3.20
D 9.60
 其他相关推荐
 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.nIf 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.nnYour task is to tally these guesses and print out how much each person wins.nnnInputnnThe 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 ','.nnProcess to the end of file.nnTallying:nnThe 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:nnTotNum: total number of guesses by all contestantsnTotShares: total number of shares from all contestantsnOffOne: number of offbyone guesses by that contestantnRightOn: number if righton guesses by that contestantnn(TotNum * $2.00) / TotShares * (OffOne + (RightOn * 2))nnnOutputnnPrint out all the winners, in alphabetical order, and their winnings, separated by a single space. Each winner should be on a line by itself.nnSeparate output for different cases by a single blank line.nnnSample Inputnnaadddddddddddddddddddddddffffffffffffffffwwwwwwwwwwwwccccalalalan4nA a:6,c:6nB w:12nC d:25nD d:22,c:4,l:3,f:15nnnSample OutputnnA 3.20nB 3.20nD 9.60
 The Counting Problem
 DescriptionnGiven two integers a and b, we write the numbers between a and b, inclusive, in a list. Your task is to calculate the number of occurrences of each digit. For example, if a = 1024 and b = 1032, the list will be n1024 1025 1026 1027 1028 1029 1030 1031 1032nnthere are ten 0's in the list, ten 1's, seven 2's, three 3's, and etc.nInputnThe input consists of up to 500 lines. Each line contains two numbers a and b where 0 < a, b < 100000000. The input is terminated by a line `0 0', which is not considered as part of the input.nOutputnFor each pair of input, output a line containing ten numbers separated by single spaces. The first number is the number of occurrences of the digit 0, the second is the number of occurrences of the digit 1, etc.nSample Inputn1 10n44 497n346 542n1199 1748n1496 1403n1004 503n1714 190n1317 854n1976 494n1001 1960n0 0nSample Outputn1 2 1 1 1 1 1 1 1 1n85 185 185 185 190 96 96 96 95 93n40 40 40 93 136 82 40 40 40 40n115 666 215 215 214 205 205 154 105 106n16 113 19 20 114 20 20 19 19 16n107 105 100 101 101 197 200 200 200 200n413 1133 503 503 503 502 502 417 402 412n196 512 186 104 87 93 97 97 142 196n398 1375 398 398 405 499 499 495 488 471n294 1256 296 296 296 296 287 286 286 247
 Counting Out
 Problem DescriptionnConsider this simple form of shuffling a deck of cards. Hold the deck face down and count to a certain number (say k), on each count taking one card from the top of the deck and placing it at the bottom. When you have finished counting, turn the top card (the k+1'th card) over and place it face up on the table. Thus cards are continually moved from the top of the deck to the bottom, even when you have fewer cards than your chosen number. Continue in this way until you have no more cards left. Thus if k was 4, you would move 4 cards, one by one, from the top of the deck to the bottom and turn over the fifth. You would then move the sixth, seventh, eighth and ninth cards to the bottom and expose the tenth. Note that the number of the exposed card is always one more than k; if k was nine you would expose every tenth card, and so on.nnWrite a program that will read in the chosen number (k) and details of a deck of cards and simulate this process. Remember that a standard deck (or pack) of cards contains 52 cards. These are divided into 4 suits  Spades, Hearts, Diamonds and Clubs. Within each suit there are 13 cards  Ace (A), 29, Ten (T), Jack (J), Queen (Q) and King (K).n nnInputnInput will consist of a series of scenarios. Each scenario will start with a number k (4 <= k <= 26) on a line by itself. This will be followed by the description of a deck. A deck will be specified on four lines with 13 cards on each line and with cards separated by exactly one space (see the example below). The cards are shown as they would be seen if they were face up, thus the last card in the sequence would be the top of the deck as far as you are concerned. The file will be terminated by a line consisting of a zero (0).nn nnOutputnOutput will consist of a series of lines, one for each scenario in the input. Each line will consist of the last card played, in the format shown below.nn nnSample Inputn4nH2 H7 SA HJ D4 S4 HT DJ C9 HQ CT H8 SQnDQ S6 D2 H5 CJ CK HA D5 D9 H9 S8 D3 C4nS2 C5 CQ D8 DT C6 DK H4 CA C8 C2 SK C7nS5 H6 H3 S9 S7 C3 SJ S3 ST HK DA D6 D7n0 n nnSample OutputnS8
 Counting Sheep
 Problem DescriptionnA while ago I had trouble sleeping. I used to lie awake, staring at the ceiling, for hours and hours. Then one day my grandmother suggested I tried counting sheep after I'd gone to bed. As always when my grandmother suggests things, I decided to try it out. The only problem was, there were no sheep around to be counted when I went to bed.nnnnCreative as I am, that wasn't going to stop me. I sat down and wrote a computer program that made a grid of characters, where # represents a sheep, while . is grass (or whatever you like, just not sheep). To make the counting a little more interesting, I also decided I wanted to count flocks of sheep instead of single sheep. Two sheep are in the same flock if they share a common side (up, down, right or left). Also, if sheep A is in the same flock as sheep B, and sheep B is in the same flock as sheep C, then sheeps A and C are in the same flock.nnnNow, I've got a new problem. Though counting these sheep actually helps me fall asleep, I find that it is extremely boring. To solve this, I've decided I need another computer program that does the counting for me. Then I'll be able to just start both these programs before I go to bed, and I'll sleep tight until the morning without any disturbances. I need you to write this program for me.n nnInputnThe first line of input contains a single number T, the number of test cases to follow.nnEach test case begins with a line containing two numbers, H and W, the height and width of the sheep grid. Then follows H lines, each containing W characters (either # or .), describing that part of the grid.n nnOutputnFor each test case, output a line containing a single number, the amount of sheep flock son that grid according to the rules stated in the problem description.nnNotes and Constraintsn0 < T <= 100n0 < H,W <= 100n nnSample Inputn2n4 4n#.#.n.#.#n#.##n.#.#n3 5n###.#n..#..n#.###n nnSample Outputn6n3n
 Counting Problem
 问题描述 :nn Yes. Counting problem comes again. n Given a chess board of N*N (N<=500), how many ways are there to put N queens on it so that no queen can attack another? n Luckily this is not the problem you should solve in this contest. Instead, we have a much easier one here.n Given a chess board of N*N (N<=500), how many ways are there to put 2*N queens on it so that there are exactly two queens in each row and each column?n To make it even easier, we will consider one way to be the same with another if it can be transformed to the other one by swapping rows and swapping columns.n输入:nn The first line of the input is an integer T indicating the number of cases. n Line 2..T+1 will contain an positive integer N (N <=500) each.n输出:nn The first line of the input is an integer T indicating the number of cases. n Line 2..T+1 will contain an positive integer N (N <=500) each.n样例输入:nn3n2n5n4n样例输出:nn1n2n2
 Counting Sundays
 Give "1 Jan 1900 was a Monday", get "How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?"
 Counting Triangles
 Problem DescriptionnGiven an equilateral triangle with n the length of its side, program to count how many triangles in it.HDU 1396 Counting TrianglesnInputnThe length n (n <= 500) of the equilateral triangle's side, one per line.nnprocess to the end of the filen nOutputnThe number of triangles in the equilateral triangle, one per line.n nSample Inputn1 2 3n nSample Outputn1 5 13n
 Counting Grids
 Problem DescriptionnSmall Ming is a lazy middle school student, one day, when he's doing his physics experiment, the teacher wants them to estimate the size of the molecule by Film Method(You Mo Fa). As is known to all, the experiment requires students to draw the outline of the Film(You MO). But Ming is so lazy that he doesn't want to draw the outline precisely. So he chooses some points on the grid plane whose coordinates are integers, and promise that , after connecting these points with segments in clockwise, you can get a convex polygon P which contains the whole Film(You Mo). Lazy Ming wants to use polygon P represented the Film to complete his experiment. But for some reasons, he forgot the points he choose on the second day.The only thing he remeber is some points with integer coordinates on the Film(You Mo) that can perfectly describe the polygon P.Now as a TopCoder and a good friend of him, can you help him to calculate the number of grids on the Film(You Mo)?n nnInputnMutilple cases. For every case, first line is an integer N(N<10^5), then N lines follow. Each line has 2 integers x and y, which describe a point on the grid plane(0<=x,y<=10^5).n nnOutputnAs described in the problem, you should calculate the number of the grids.n nnSample Inputn3n0 0n0 1n1 1n nnSample Outputn1
 word counting
 输出一段字串中的字符数——程序很小，第一次上传，大家多支持！
 Dight Counting（字符串转数字）
 题目 Trung is bored with his mathematics homeworks.He takes a piece of chalk and starts writing a sequence of consecutive integers starting with1 to N (1&lt;N&lt;10000).After that,he counts the number o...
 Reference Counting（引用计数）
 数据成员包括数组 涉及到深复制与浅复制 提高深复制效率——引用计数 data* + recount 拷贝构造函数 共享指针，recount+1 赋值构造函数 recount1 至0 delete，共享指针，recount+1 析构函数 recount1 至0 delete 写时复制 “和其他对象共享一份数据实体，直到必须对自己拥有的那份实值进行写操作” 重载nonconst []运算符 检查...
 Higher Maths Counting Part2
 Year One, Higher Math Lecture Notes. Math1141
 算法之计数排序（Counting Sort）
 计数排序的核心在于将输入的数据值转化为键存储在额外开辟的数组空间中。 作为一种线性时间复杂度的排序，计数排序要求输入的数据必须是有确定范围的整数。 计数排序(Counting sort)是一种稳定的排序算法。计数排序使用一个额外的数组C，其中第i个元素是待排序数组A中值等于i的元素的个数。 然后根据数组C来将A中的元素排到正确的位置。它只能对整数进行排序。 1 算法描述 找出...
 Model Counting, Quantification, and Randomization
 It's useful for Model Counting, Quantification, and Randomization
 The Pleasures of Counting 1996
 The Pleasures of Counting 1996 © Cambridge University Press 1996
 Ant Counting（多重集组合数）
 原体链接Language: Ant Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4895 Accepted: 1866 DescriptionBessie was poking around the ant hill one day watching the ants march t
 counting 代码行数统计
 一个统计代码行的很简单很适用的小工具a statistical line of code is very simple and very applicable to the small tools
 Lake Counting（深度优先算法）
 这个题的模板 也可以AC 另两个题 ，代码意思都是差不多的 Red and Black（找黑砖的个数）点击打开链接 Oil Deposits（计算油田的个数）点击打开链接 Description Due to recent rains, water has pooled in various places in Farmer John's field, which is rep...
 Lake Counting 算法 第四集
 本题还是一个关于深度优先搜索和递归的算法题，原题如下： 有一个大小为N*M的园子，雨后积起了水，八连通被认为是连接在一起的，请求出园子里总共有多少洼？（八连通指的是下图中相对W的*的部分） * * * * w * * * * 限制条件： N,M 本题的代码实现如下： #include "stdafx.h" #include #include #define MAX_N 100
 计数排序（Counting Sort）
 计数排序假设n个输入元素中的每一个都是介于0k的整数，此处k为某个整数。计数排序顾名思义离不开计数，我们要计的是输入元素中相同元素出现的次数。对每一个输入元素x，确定小于x的元素的个数，那样排序之后，x在最终输出数组中的位置就可以确定了。例如：如果有17个元素小于x，则x就位于第18个输出的位置上。当然有几个元素相同时，这个方法就略微改进一下，因为不能将它们放在同一个位置上。 假定输入数...
 排序算法之计数排序（Counting Sort）
 计数排序 今天看了计数排序，感觉十分有趣，记录一下。 要用到collections库种的defaultdict，代码如下： from collections import defaultdict def counting_sort(seq, key=lambda x: x): sorted_seq, my_dict = [], defaultdict(list) f...
 Crowd Counting（人群计数）
 SingleImage Crowd Counting via MultiColumn Convolutional Neural Network（CVPR_2016）We have proposed a simple but effective Multicolumn Convolutional Neural Network (MCNN) architecture to map the ima...
 Project 2: Counting Leaves
 A family hierarchy等级 is usually presented by a pedigree tree系谱树. Your job is to count those family members who have no child.
 AlgorithmMan by Iori（Counting Sort）
 AlgorithmMan by Iori，AlgorithmMan是使用Winform技术开发的一套用于算法演示的工具。 CountingSort为AlgorithmMan中的计数排序演示工具（这是可执行文件；需要.net 4.0支持；非源代码）。 原文：C#算法设计排序篇之08计数排序（附带动画演示程序） 链接：https://blog.csdn.net/qq_31116753/article/details/81610602
 source统计工具Counting
 可以统计source有效行，空行,注释行，文件的大小，统计的文件数目的工具
 Counting Cliques （优雅爆搜）
 Sample Input 3 4 3 2 1 2 2 3 3 4 5 9 3 1 3 1 4 1 5 2 3 2 4 2 5 3 4 3 5 4 5 6 15 4 1 2 1 3 1 4 1 5 1 6 2 3 2 4 2 5 2 6 3 4 3 5 3 6 4 5 4 6 5 6 Sample Output 3 7 15 ...
 338. Counting Bits（动态规划）
 https://leetcode.com/problems/countingbits/description/题目：求0~num中每个数1的个数。思路：动态规划，方程，v[n]=v[n>>1]+n%2。class Solution { public: vector<int> countBits(int num) { vector<int>v;v.push_back(0);
 Counting Objects in C++
 It isn't hard to keep a count of all the objects allocated for a given class in C++, unless you have to deal with distractions.
 simple rainflow counting algorithms
 s.D.Downing and D.F.Socie fortran Code
 Counting Words（句子切割）
 Input some English sentences, count and print the numbers of all the words and each different words./** * Created by 孙月晴 on 2017/7/18. */ import java.util.Scanner; import java.util.HashMap; import ja
 Counting代码量统计工具
 统计代码量的工具 软件开发必备 简单易操作
 水池数目和Lake Counting
 题目链接：http://acm.nyist.net/JudgeOnline/problem.php?pid=27 本题是一道全覆盖的搜索题，建议遇到全覆盖问题先采用dfs，dfs不行再选用bfs，而且本题采用了DFS，这道题和POJ上的一道题进行比较，两题只差在相邻的几个点算一个池子 水池数目：必须在DFS中更新地图标记 #include #include #include using n
 Counting Bits（统计比特位）
 Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array.（给定一个非负整数num，对每个在0<=i<=num范围
 Counting源代码统计器
 Counting源代码统计器，对开发的代码进行统计，辅助开发者进行开发，也可以用于软件测试时对代码的统计
 Lake Counting 搜索（水题）
 Lake Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 47206 Accepted: 23209 Description Due to recent rains, water has pooled in various places in Farmer John’s ...
 Lake Counting（湖泊计数）
 今天做了一个挺有趣的问题，下面我将叙述并给出结题代码 #include&lt;bits/stdc++.h&gt; using namespace std; char a[101][101]; int n,m; int sum=0; void judge(int x,int y)//用于判定第x行第y列相邻8个单元 { int i,j; a[x][y]='.';...
 Counting 2nd, NUS Singapore
 An Introduction to Differential Equations: Volume 2 is a stochastic version of Volume 1 (An Introduction to Differential Equations: Deterministic Modeling, Methods and Analysis). Both books have a similar design, but naturally, differ by calculi. Again, both volumes use an innovative style in the presentation of the topics, methods and concepts with adequate preparation in deterministic Calculus.
 Counting代码参考
 Counting Time Limit:1000MS Memory Limit:65536K Total Submit:631 Accepted:256 Description 问题描述： 一本书的页码从自然数1 开始顺序编码直到自然数n。书的页码按照通常的习惯编排，每个页码都不含多余的前导数字0。例如，第6 页用数字6 表示，而不是06 或006 等。数字计数问题要求对给定书的总页码n，计算出书的全部页码中分别用到多少次数字0，1，2，…，9。 编程任务： 给定表示书的总页码的10 进制整数n (1≤n≤10^9) 。使用递归与分治策略编程计算书的全部页码中分别用到多少次数字0，1，2，…，9。 Input 输入由多组测试数据组成。 每组测试数据输入只有1 行，给出表示书的总页码的整数n。 Output 对应每组输入，输出共有10行，在第k行输出页码中用到数字k1 的次数，k=1，2，…，10。 Sample Input 11 Sample Output 1 4 1 1 1 1 1 1 1 1 Hint 注意：必须使用递归与分治策略编程
 1004. Counting Leaves (30)
 1004. Counting Leaves (30) 来自：http://blog.csdn.net/sunbaigui/article/details/8657008
 C语言模拟考Counting
 Description: Given an integer N, please count its reverse,how many digits in N,and then add all digits. Sample input: 1565702642762530364052732515657026427625303640527325156570264276253036405