首页| JavaScript| HTML/CSS| Matlab| PHP| Python| Java| C/C++/VC++| C#| ASP| 其他|
购买积分 购买会员 激活码充值

您现在的位置是:虫虫源码 > 其他 > 2012 codepsu实例问题

2012 codepsu实例问题

  • 资源大小:2.49 kB
  • 上传时间:2021-06-30
  • 下载次数:0次
  • 浏览次数:0次
  • 资源积分:1积分
  • 标      签: 实例 问题

资 源 简 介

Given a set of N numbers (N ≤ 105), we need to count the total pairs of numbers that have a difference of K (0 < K < 109). Input Input will consist of multiple test cases. Each test case will consist of two lines. The first line will contain two positive integers in the format N K. The first specifies how many numbers are in the set and the second is the desired difference. The second line contains the N numbers of the set, each separated by a single space. All of the N numbers are assured to be distinct. Output For each test case, output a single line with one integer representing how many pairs of numbers from the set have a difference of K. Sample Input 5 2 1 5 3 4 2 9 1 363374326 364147530 61825163 1073065718 1281246024 1399469912 428047635 491595254 879792181 Sample Output 3 0
VIP VIP
0.172280s