evildav

k difference

Jun 10th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.28 KB | None | 0 0
  1. $s = <STDIN>;
  2. my ($N, $K, @arr);
  3. ($N, $K) = split /\s/, $s;
  4. $s = <STDIN>;
  5. @arr = split /\s/, $s;
  6. my %hash;
  7. my $cnt = 0;
  8. my %intersectlist;
  9. foreach my $k(@arr) {
  10.         $intersectlist{$k + $K} = 1;
  11. }
  12. for my $k(@arr) {
  13.         $cnt++ if exists $intersectlist{$k};
  14. }
  15. print $cnt;
Advertisement
Add Comment
Please, Sign In to add comment