Milly and SPA
Practice
3.4 (245 votes)
Easy
Problem
27% Success 1940 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Milly is a very cool algorithmist. She likes to make new algorithms to solve real world scenarios. This time she is playing with strings and she is trying to produce some new concept out of it. She has developed a new concept of SPA which stands for STRING POINT AVERAGE. This concept is described below :

Suppose we have a string S, Then :

enter image description here

Here ,

             C[ch]: Count of a character ch in S,
             W[ch]: Weight of the character ch,
              TL:   Total length of S and
              TW:   Total Weight of unique characters of S

Input

  • First line of the input will contain a integer T (number of test cases).
  • Then for every test case there will be two lines, First one will have the string S and the other one will have 26 space separated integers denoting W[ch].

Output

  • For every test case, print the required SPA and Your answer will be considered as correct if it has an absolute error less than 10-2.

Constraints

  • 1 ≤ T ≤ 10
  • 1 ≤ W[ch] ≤ 100
  • 1 ≤ TL ≤ 105
  • ch ∈ {a, b, c ... ,z}

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
6 votes
Tags:
AlgorithmsDepth First SearchGraphsMedium
Points:20
8 votes
Tags:
CombinatoricsEasyMath
Points:20
7 votes
Tags:
Dynamic ProgrammingRecursionAlgorithmsEasyMathematicsOpenApproved