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