Đếm cặp

View as PDF




Problem type
Points: 200 (p) Time limit: 1.0s Memory limit: 640M Input: stdin Output: stdout

Cho dãy số nguyên dương gồm \(N\) phần tử \(a_1,a_2,...,a_N\). Đếm số cặp chỉ số \((i,j)\) thỏa mãn:

  • \(1 \le i \le j \le n\);
  • \(a_i + a_j^2=K\) với \(K\) cho trước.

Input

  • Dòng đầu tiên gồm 2 số nguyên dương \(N\)\(K\) \((N \le 10^5,K \le 10^9)\)
  • Dòng thứ hai chứa \(N\) số nguyên dương \(a_1,a_2,...,a_N\) \((a_i \le 10^9)\)

Output

  • In ra số cặp \((i,j)\) thỏa mãn.

Example

Test 1

Input
3 5
1 2 2 
Output
2

Comments

There are no comments at the moment.