2018 US group comments spring C ++ exam programming questions, 2018 US dollars

Source: Internet
Author: User

2018 US group comments spring C ++ exam programming questions, 2018 US dollars

Comments from the US Mission: 2018 online examination for the development direction of the spring recruitment background

Programming question | 30.0 points 1/2

String distance

Time limit:The C/C ++ language is 2000 MS; other languages are 4000 MS.
Memory limit:C/C ++ language 65536KB; other languages 589213kb

Description:

Two strings of the same length composed of characters a and B are given, and their distance is defined as the number of characters at different positions. For example, the distance between string "aab" and string "aba" is 2; the distance between string "ba" and string "aa" is 1; the distance between the string "baa" and the string "baa" is 0. The following two strings S and T are given. The length of S is not less than the length of T. | S | represents the length of S, | T | represents the length of T, in S, there is a total of | S |-| T | + 1 substrings with the same length as T, now you need to calculate the sum of the distance between the T string and the | S |-| T | + 1 substring.

Input

The first line contains a string S.

The second line contains a string T.

S and T are both composed of characters a and B. 1 ≤ | T | ≤ | S | ≤ 105 ?.

Output

Output the corresponding answer.

?

Sample Input

Aab

Aba

Sample output

2

?

Hint

Input Sample 2

Aaabb

Bab

Output Sample 2

5

In Example 2, the distance between "aaa" and "bab" is 2, and the distance between "aab" and "bab" is 1, the distance between "abb" and "bab" is 2,

So the final answer is 5.

Tip

Please try to debug the program 10 minutes before the end of the test. Otherwise, the compilation results may not be found due to intensive queue submission?
Click "debug" to save the code.
You can use a local compiler for programming questions. This page does not record the number of jumps.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.