#CCBOTPBA0000042. Sum of Odd Integers
Sum of Odd Integers
Sum of Odd Integers
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive n,k, determine whether n is the sum of exactly k pairwise distinct positive odd integers. PHOJ accepts one n,k pair; the original Codeforces version has t cases.
Input
Two positive integers n k.
Output
Print YES if possible; otherwise NO.
Subtasks
-
Subtask 1 (20%):
1 ≤ n,k ≤ 100. -
Subtask 2 (30%):
1 ≤ n,k ≤ 10^5. -
Subtask 3 (50%):
1 ≤ n,k ≤ 10^7.
Examples
Example 1
Input:
10 2
Output:
YES
Explanation: 10=3+7 uses two distinct odd positive integers.
Example 2
Input:
10 3
Output:
NO
Explanation: Three odd integers have odd sum, not ten.
Example 3
Input:
16 4
Output:
YES
Explanation: The smallest four distinct positive odd integers sum to 16.