2 条题解

  • 0
    @ 2026-3-23 13:34:14

    t = int(input()) for _ in range(t): n, k = map(int, input().split()) a = [0] + list(map(int, input().split()))

    ans = 10**9
    for color in range(1, 61):
        cnt = 0
        j = 1
        while j <= n:
            if a[j] != color:
                cnt += 1
                j += k
            else:
                j += 1
        ans = min(ans, cnt)
    
    print(ans)
    
    • 0
      @ 2026-3-14 9:05:37

      #include<bits/stdc++.h> using namespace std; int main(){ int n; int a,b; scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d %d",&a,&b);int m[a]={0}; for(int j=0;j<a;j++){ scanf("%d",&m[j]); } int ans[61]={0}; for(int k=1;k<=60;k++){ for(int p=0;p<a;){ if(k!=m[p]){p=p+b;ans[k]++; }else{p=p+1; } } } sort(ans,ans+61);printf("%d\n",ans[1]); } }嘿嘿

      • 1

      信息

      ID
      597
      时间
      1000ms
      内存
      256MiB
      难度
      2
      标签
      递交数
      111
      已通过
      47
      上传者