• [B] Radical is down

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • Last week,Radical gave you a problem , but only one guy solved it.He's very down,so today he prepares a simple problem for you.
    We all known arrays.And now I want to tell you a K-Periodic array whose length is divisible by k.
    For example,array[2,1,2,1,2,1]is at the same time 2-periodic and 6-periodic.
    For the given array,consisits of numbers one and two,find the minimum numbers of elements to change to make the array
    K-Periodic.If the array already is k-periodic, then the required value equals 0.

  • 输入
  • The first line of the input contains a pair of integers n,k(1<=k<=n<=100),where n is the length of the array and n is
    divisible by k.The second line contains the sequence of elements of the given array a1,a2...,an (1≤ai≤2),
    ai is the i-th element of the array.
  • 输出
  • Print the minimum number of the array elements we need to change to make the array K-Periodic.
  • 样例输入
  • 6 2
    2 1 2 2 2 1
    9 3
    2 1 1 1 2 1 1 1 2
  • 样例输出
  • 1
    3
  • 提示
  • 来源
  • Radical@NBUT
  • 操作

显示春菜