Tina has recently been introduced to a programming concept called Hashing.
Hashing is the transformation of a string of characters into a usually shorter fixed-length value or key that represents the original string.
Hashing is used to index and retrieve items in a database because it is faster to find the item using the shorter hashed key than to find it using the original value. sources: Internet
As a homework, her teacher has given a string and asked her to find no of strings she can make using each of the alphabet as starting character. Though she has already solved the question, she isn’t sure if her answers are correct.
Help her by telling the correct answer of all the questions.
For each alphabet, print the remainder obtained by dividing the answer by 1000000007.
Input:
Only line of Input has a single string.
Output:
26 integers denoting no of strings that can be made by using each of the alphabet as starting character.
#include <stdio.h> #include <string.h> int factorial(int n) { if(n>=1) return n*factorial(n-1); else return 1; } int main() { char string[100]; scanf("%s",string); int arr[26]={},i; int len=strlen(string); for(i=0;i<len;i++) arr[string[i]-'a']=factorial(len-1); for(i=0;i<26;i++) printf("%d ",arr[i]); return 0; }
INPUT_1:
shimla
OUTPUT:
120 0 0 0 0 0 0 120 120 0 0 120 120 0 0 0 0 0 120 0 0 0 0 0 0 0
INPUT_2:
hampi
OUTPUT:
24 0 0 0 0 0 0 24 24 0 0 0 24 0 0 24 0 0 0 0 0 0 0 0 0 0
INPUT_3:
fcukthecode
OUTPUT:
0 0 3628800 3628800 3628800 3628800 0 3628800 0 0 3628800 0 0 0 3628800 0 0 0 0 3628800 3628800 0 0 0 0 0
INPUT_4:
ZatchBell
OUTPUT:
40320 0 40320 0 40320 0 0 40320 0 0 0 40320 0 0 0 0 0 0 0 40320 0 0 0 0 0 0
ILLUSTRATION
Morae Q!
- Find the number of strings made by using each alphabet as starting character.
- Find the Pythagorean triplet.
- Find out what is the minimum possible energy he needs to spend.
- Sort the array in non-decreasing order and print out the original indices of sorted array.
- Compute the number of landmasses on the planet after all the meteorites have fallen.
- Give the appropriate server status as output.
- Regular expressions (Regex) using search module in python.
- Find the minimum distance between any pair of equal elements in the array.
- Find the total number of matching pairs of socks that are available.
- Find the total number of teams which can work together and cannot work together.
- Given the heights of all the boys and girls tell whether it is possible for all boys to get a girl.
- Find the sequence of cities to visit according to coordinates and conditions.
- Find the number of unique patches of rectangular land to grow samba(rice) in.
- Regular expression Regex matching strings.
- Generate a greeting quote for admin.
- Find all the cavities on the map and replace their depths with the character X.
- Check whether the given graph is Bipartite or not.
- Find the status of the passengers and safari cars at zoo after k units of time.
- Determine the chair number occupied by the child who will receive that chocolate.
- Check if Rubik’s cube of any dimensions can be assembled.