@@ -0,0 +1,1801 @@
+//https://www.hackerrank.com/challenges/sherlock-and-probability%0Aimport java.io.*;%0A%0Apublic class Solution %7B%0A%0A    public static void main(String%5B%5D args) throws IOException %7B%0A        final StringBuffer sb = new StringBuffer();%0A        %0A        //INPUT%0A        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));%0A        for(int T = Integer.parseInt(br.readLine()); T %3E 0; --T)%7B%0A            String%5B%5D input = br.readLine().split(%22 %22);%0A            final int N = Integer.parseInt(input%5B0%5D);%0A            final int K = Integer.parseInt(input%5B1%5D);%0A            char%5B%5D str = br.readLine().toCharArray();%0A            input = null;%0A            %0A            //INIT%0A            final byte%5B%5D B = new byte%5BN%5D;%0A            for(int i = 0; i %3C N; ++i)%7B%0A                B%5Bi%5D = (byte)(str%5Bi%5D - '0');%0A            %7D%0A            str = null;%0A            %0A            //SOLVE%0A            long num = 0;%0A            long den = 1L * N * N;%0A            %0A            int sum = 0;%0A            for(int i = 0; i %3C K; sum += B%5Bi++%5D)%7B%7D%0A            %0A            for(int i = 0; i %3C N-K; ++i)%7B%0A                sum += B%5Bi+K%5D;%0A                if (B%5Bi%5D == 1)%7B%0A                    num += 1 + (--sum %3C%3C 1);%0A                %7D%0A            %7D%0A            %0A            for(int i = N-K; i %3C N; ++i)%7B%0A                if (B%5Bi%5D == 1)%7B%0A                    num += 1 + (--sum %3C%3C 1);%0A                %7D%0A            %7D%0A            %0A            final long factor = gcd(num, den);%0A            num /= factor;%0A            den /= factor;%0A            %0A            //OUTPUT%0A            sb.append(num + %22/%22 + den + %22%5Cn%22);%0A        %7D%0A        System.out.print(sb);%0A    %7D%0A    %0A    private static long gcd(long a, long b)%7B%0A        while (b != 0)%7B%0A            long c = a;%0A            a = b;%0A            b = c%25b;%0A        %7D%0A        return a;%0A    %7D%0A%7D%0A

Create sherlock-and-probability.java