题目
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int t = sc.nextInt();sc.nextLine();int[] res = new int[t];for(int i=0;i<t;i++) {int ans = Integer.MAX_VALUE;int n = sc.nextInt();int k = sc.nextInt();sc.nextLine();int[] colors = new int[n];for(int j=0;j<n;j++)colors[j] = sc.nextInt();for(int a=1;a<=60;a++) {int s = 0;for(int b=0;b<n;b++) {if(colors[b] == a) { continue;}s++;b+=(k-1);}ans = Math.min(ans, s);}res[i] = ans;}for(int i=0;i<t;i++) {System.out.println(res[i]);}sc.close();}
}
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int t = sc.nextInt();sc.nextLine();while(t!=0) {int ans = Integer.MAX_VALUE;int n = sc.nextInt();int k = sc.nextInt();sc.nextLine();int[] colors = new int[n];for(int i=0;i<n;i++) {colors[i] = sc.nextInt();}for(int i=1;i<=60;i++) {int s = 0;//所需要的天数for(int j=0;j<n;j++) {if(colors[j] == i)continue;s++;//天数加一//j+=k;//一天可以涂k长度j+=k-1;//一天可以涂k长度(j++)加了一次1}ans = Math.min(ans, s);}System.out.println(ans);t--;}sc.close();}
}