Advertisement
Guest User

Untitled

a guest
Mar 4th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var mas:array[1..100000] of longint;
  2.     ans_full:qword;
  3.     i,j,n,k:longint;
  4.  
  5. function abc(a,b: longint): integer;
  6.     var k1,k2,ans: longint;
  7. begin
  8.     ans:=0;
  9.     while (a>0) and (b>0) do
  10.         begin
  11.             k1:= a mod 2;
  12.             k2:= b mod 2;
  13.             if k1 <> k2 then    inc(ans);
  14.             a:= a div 2;
  15.             b:= b div 2;
  16.         end;
  17.     exit(ans);
  18. end;
  19.  
  20. begin
  21. assign(input,'input.txt');
  22. reset(input);
  23. assign(output,'output2.txt');
  24. rewrite(output);
  25.  
  26.     readln(n,k);
  27.     for i:=1 to n do
  28.         read(mas[i]);
  29.  
  30.     ans_full:=0;
  31.  
  32.     for i:=1 to n do
  33.         for j:=i+1 to n do
  34.             if abc(mas[i],mas[j]) = k then inc(ans_full);
  35.    writeln(ans_full);
  36.  
  37. close(input);
  38. close(output);
  39. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement