TỔNG BẰNG K

PDF

Submit solution

Points: 10.00 (partial)
Time limit: 1.0s
Memory limit: 64M
Input: stdin
Output: stdout

Problem types
Allowed languages
C, C++, Java, Pascal, Python, Scratch, TEXT

Cho dãy số nguyên \(a=(~a_1,a_2,…,a_n~)\), gồm ~n~ phần tử.

Yêu cầu

Hãy đếm xem có bao nhiêu cặp vị trí ~i, j~ ~(i \lt j)~ sao cho ~a_i~ + ~a_j = k ~

Dữ liệu

  • Dòng 1 chứa hai số nguyên dương ~n, k~.
  • Dòng 2 chứa ~n~ số nguyên ~a_1,a_2,…,a_n~ cách nhau bởi dấu cách.

Kết quả

  • Xuất ra số cặp tìm được.

Giới hạn

  • ~n \leq 10^5~
  • ~|k| \leq 2.10^9~
  • |~a_i~| ~\leq~ ~10^9~

Input

4 3
1 2 1 4

Output

2

Comments

Please read the guidelines before commenting.


There are no comments at the moment.