Category
Similar Problems
0799. Hamming distance
Time limit : 1000 ms
Memory limit : 64 mb
Richard Hemming
In information theory, the Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. In another way, it measures the minimum number of substitutions required to change one string into the other, or the minimum number of errors that could have transformed one string into the other. Let us define Hamming distance as d(s1, s2). For example: d(tatuuf, tuitub)= 4, d(more, code)=2, d(algo, algo)=0. In this problem you are given two strings s and t. Your task is to calculate the sum of Hamming distances beetween t and all substrings of s.
Input
In the first line given s , in the secont given t. Both strings contain lowercase english letters (1≤|t|≤|s|≤106). |x| - the length of string x.
Output
Output the answer to problem.
Examples
№ |
Input |
Output |
1 |
azat ozod |
3 |
2 |
abdavcaeaada abda |
24 |
2015 yil Dasturlash bo'yicha Tatu va uning filiallari talabalari o'rtasida jamoaviy olimpiada. Final. Urgench 21-23 aprel.