#CCBCHBA0000103. Đếm cặp có tổng k (Count Pairs with Sum k)
Đếm cặp có tổng k (Count Pairs with Sum k)
Count Pairs with Sum k
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given , count pairs of integers satisfying and . Each unordered pair is counted exactly once; print 0 if none exists.
Input
One line contains two integers .
Output
Print the number of valid pairs.
Subtasks
-
Subtask 1 (20%): ; .
-
Subtask 2 (30%): ; .
-
Subtask 3 (50%): ; .
Examples
Example 1
Input:
4 5
Output:
2
Explanation:
For n=4, k=5, qualifying pairs are (1,4), (2,3); the answer is 2.
Example 2
Input:
1 2
Output:
0
Explanation:
For n=1, k=2, qualifying pairs are none; the answer is 0.