codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1352B.md (1392B)


      1 Source: https://codeforces.com/problemset/problem/1352/B
      2 
      3 B. Same Parity Summands
      4 
      5 time limit per test
      6 
      7 1 second
      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 positive integers $n$ ($1 \le n \le 10^9$) and $k$ ($1 \le k \le 100$). Represent the number $n$ as the sum of $k$ positive integers of the same parity (have the same remainder when divided by $2$).
     22 
     23 In other words, find $a_1, a_2, \ldots, a_k$ such that all $a_i \gt 0$, $n = a_1 + a_2 + \ldots + a_k$ and either all $a_i$ are even or all $a_i$ are odd at the same time.
     24 
     25 If such a representation does not exist, then report it.
     26 
     27 Input
     28 
     29 The first line contains an integer $t$ ($1 \le t \le 1000$) — the number of test cases in the input. Next, $t$ test cases are given, one per line.
     30 
     31 Each test case is two positive integers $n$ ($1 \le n \le 10^9$) and $k$ ($1 \le k \le 100$).
     32 
     33 Output
     34 
     35 For each test case print:
     36 
     37 * YES and the required values $a_i$, if the answer exists (if there are several answers, print any of them);
     38 * NO if the answer does not exist.
     39 
     40 The letters in the words YES and NO can be printed in any case.
     41 
     42 Example
     43 
     44 Input
     45 
     46 ```
     47 8
     48 10 3
     49 100 4
     50 8 7
     51 97 2
     52 8 8
     53 3 10
     54 5 3
     55 1000000000 9
     56 ```
     57 
     58 Output
     59 
     60 ```
     61 YES
     62 4 2 4
     63 YES
     64 55 5 5 35
     65 NO
     66 NO
     67 YES
     68 1 1 1 1 1 1 1 1
     69 NO
     70 YES
     71 3 1 1
     72 YES
     73 111111110 111111110 111111110 111111110 111111110 111111110 111111110 111111110 111111120
     74 ```