编程介的小学生 2017-08-03 15:44 采纳率: 20.5%
浏览 920
已采纳

Jewelry

Problem Description
After all the difficulties, Psyche and Cupid are finally getting married.

No ordinary pearls can hold Cupid's love for Psyche. So he has collected the Jewelry of Gods at the top of Mount Olympus to make her a chain.

There are n beads on the chain. The i-th bead is of the type Ai.

Being pretty in appearance and generous in her heart, Psyche decides to give one consecutive part of the chain to her mother.

To meet her mother's particular taste, that part must have at least one type of bead that appears x times exactly.

Psyche wants to know the number of ways to choose a part of the chain for her mother.

Note that two parts [L1,R1] and [L2,R2] are different only if L1≠L2 or R1≠R2.

Input
The first line of the input contains an integer T (1≤T≤15), which denotes the number of test cases.

For each test case, the first line contains two integers n,x (1≤n≤105,1≤x≤n).

The second line contains n integers, the i-th integer denotes Ai (0≤Ai≤109).

Output
For each test case, print an integer which denotes the number of parts Psyche can choose.

Sample Input
2
3 1
1 2 1
4 2
2 3 2 2

Sample Output
6
3

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-08-18 15:53
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?