1327A.md (1405B)
1 Source: https://codeforces.com/problemset/problem/1327/A 2 3 A. Sum of Odd Integers 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 You are given two integers $n$ and $k$. Your task is to find if $n$ can be represented as a sum of $k$ distinct positive odd (not divisible by $2$) integers or not. 22 23 You have to answer $t$ independent test cases. 24 25 Input 26 27 The first line of the input contains one integer $t$ ($1 \le t \le 10^5$) — the number of test cases. 28 29 The next $t$ lines describe test cases. The only line of the test case contains two integers $n$ and $k$ ($1 \le n, k \le 10^7$). 30 31 Output 32 33 For each test case, print the answer — "YES" (without quotes) if $n$ can be represented as a sum of $k$ distinct positive odd (not divisible by $2$) integers and "NO" otherwise. 34 35 Example 36 37 Input 38 39 ``` 40 6 41 3 1 42 4 2 43 10 3 44 10 2 45 16 4 46 16 5 47 ``` 48 49 Output 50 51 ``` 52 YES 53 YES 54 NO 55 YES 56 YES 57 NO 58 ``` 59 60 Note 61 62 In the first test case, you can represent $3$ as $3$. 63 64 In the second test case, the only way to represent $4$ is $1+3$. 65 66 In the third test case, you cannot represent $10$ as the sum of three distinct positive odd integers. 67 68 In the fourth test case, you can represent $10$ as $3+7$, for example. 69 70 In the fifth test case, you can represent $16$ as $1+3+5+7$. 71 72 In the sixth test case, you cannot represent $16$ as the sum of five distinct positive odd integers.