# The matching string of--gg of Guang Gong School race

Source: Internet
Author: User

Description

2015 Guangdong University of Technology ACM School Race to come to ~\ (≧▽≦)/~ spicy spicy, as one of the school game, GG came up with a water problem to test everyone. Believe that the small partners have learned the string match, so the string matching water problem is born spicy! GG gives a sequence of uppercase letters of length n, and now he wants you to modify this sequence of letters so that the first K-letter sequence on this sequence of letters matches the K-letter sequence one by one of the last face.

For example, for the sequence "Atuuuuac" and k = 2, you can change the second letter to "C", so that the first two letters and the last two letters are "AC", of course, there are other methods of modification, now GG asks you to find out how many letters to make a string match at least.

Input

There is a T set of data input. (T <= 100)
Each set of data has only two rows, the first behaves as a string, the second behaves as a positive integer k, and the string length does not exceed 1000 and is at least 1. (1 <= K <= N).

Output

Minimum number of letters to modify for each set of data output

Sample Input2ATUUUUAC2ATACGTCT6Sample Output -HINT

The main idea: the topic meaning has been understood wrong, should be a string, and is the total number of changes, not the number of letters modified--| | Language needs to be improved

`#include <cstring>#include<algorithm>#include<cstdio>using namespacestd;intans;Charch[1100];intarr[ -];intT,k,n;intFintx) {memset (arr,0,sizeof(arr)); intRe =0; intR=0;  while(X <N) {R++; ARR[CH[X]-'A']++; X+=n-K; }     for(inti =0; I < -; i++) Re=Max (re,arr[i]); returnRre;}intMain () {scanf ("%d",&T);  while(t--) {scanf ("%s%d",ch,&k); N=strlen (CH); intAns =0;  for(inti =0; I < K && I < n-k; i++) ans+=f (i); printf ("%d\n", ans); }    return 0;}`
View Code

The matching string of--gg of Guang Gong School race

Related Keywords:

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.