Gửi bài giải
Điểm:
1,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Given a sequence ~A~ of ~n~ positive integers ~A_1, A_2, \ldots, A_n~. Each element does not exceed ~10^9~ and ~n \leq 10^5~. A pair of numbers is called a pair that matches ~ x~ if the sum of the pair equals a given number ~ x ~.
Requirement: Count how many pairs ~(A_i, A_j) ~ in the sequence ~ A ~ match ~ x ~ (i.e., ~ A_i + A_j = x ~) with ~ i < j \leq n~.
Input
- The first line contains the integers ~ n ~ and ~ x ~ ~( n \leq 10^5~ and ~x \leq 10^9 )~.
- The second line contains ~ n ~ elements of the sequence ~ A ~ ~( A_i \leq 10^9 )~.
Output
- Output an integer representing the number of matching pairs in the sequence.
Sample Input
7 6
1 2 4 3 4 5 3
Sample Output
4
Bình luận