CF1811G1.Vlad and the Nice Paths (easy version)
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is an easy version of the problem, it differs from the hard one only by constraints on n and k .
Vlad found a row of n tiles and the integer k . The tiles are indexed from left to right and the i -th tile has the color ci . After a little thought, he decided what to do with it.
You can start from any tile and jump to any number of tiles right, forming the path p . Let's call the path p of length m nice if:
- p can be divided into blocks of length exactly k , that is, m is divisible by k ;
- cp1=cp2=…=cpk ;
- cpk+1=cpk+2=…=cp2k ;
- …
- cpm−k+1=cpm−k+2=…=cpm ;
Your task is to find the number of nice paths of maximum length. Since this number may be too large, print it modulo 109+7 .
输入格式
The first line of each test contains the integer t ( 1≤t≤104 ) — the number of test cases in the test.
The first line of each test case contains two integers n and k ( 1≤k≤n≤100 ) — the number of tiles in a row and the length of the block.
The second line of each test case contains n integers c1,c2,c3,…,cn ( 1≤ci≤n ) — tile colors.
It is guaranteed that the sum of n3 over all test cases does not exceed 5⋅106 .
输出格式
Print t numbers, each of which is the answer to the corresponding test case — the number of nice paths of maximum length modulo 109+7 .
输入输出样例
输入#1
5 5 2 1 2 3 4 5 7 2 1 3 1 3 3 1 3 11 4 1 1 1 1 1 1 1 1 1 1 1 5 2 1 1 2 2 2 5 1 1 2 3 4 5
输出#1
1 4 165 3 1
说明/提示
In the first sample, it is impossible to make a nice path with a length greater than 0 .
In the second sample, we are interested in the following paths:
- 1→3→4→5
- 2→4→5→7
- 1→3→5→7
- 1→3→4→7
In the third example, any path of length 8 is nice.