codeforces-scrape

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

2041E.md (1724B)


      1 Source: https://codeforces.com/problemset/problem/2041/E
      2 
      3 E. Beautiful Array
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 1024 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 ![](https://espresso.codeforces.com/85676b5fd448285fb7e2f3e76ae329d7343d2bb5.png) Image generated by ChatGPT 4o. 
     22 
     23 A-Ming's birthday is coming and his friend A-May decided to give him an integer array as a present. A-Ming has two favorite numbers $a$ and $b$, and he thinks an array is beautiful if its mean is exactly $a$ and its median is exactly $b$. Please help A-May find a beautiful array so her gift can impress A-Ming.
     24 
     25 The mean of an array is its sum divided by its length. For example, the mean of array $[3, -1, 5, 5]$ is $12 \div 4 = 3$.
     26 
     27 The median of an array is its middle element after sorting if its length is odd, or the mean of two middle elements after sorting if its length is even. For example, the median of $[1, 1, 2, 4, 8]$ is $2$ and the median of $[3, -1, 5, 5]$ is $(3 + 5) \div 2 = 4$.
     28 
     29 Note that the mean and median are not rounded to an integer. For example, the mean of array $[1, 2]$ is $1.5$.
     30 
     31 Input
     32 
     33 The only line contains two integers $a$ and $b$.
     34 
     35 * $-100 \leq a, b \leq 100$.
     36 * The length of the array must be between $1$ and $1000$.
     37 * The elements of the array must be integers and their absolute values must not exceed $10^6$.
     38 
     39 Output
     40 
     41 In the first line, print the length of the array.
     42 
     43 In the second line, print the elements of the array.
     44 
     45 If there are multiple solutions, you can print any. It can be proved that, under the constraints of the problem, a solution always exists.
     46 
     47 Examples
     48 
     49 Input
     50 
     51 ```
     52 3 4
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 4
     59 3 -1 5 5
     60 ```
     61 
     62 Input
     63 
     64 ```
     65 -100 -100
     66 ```
     67 
     68 Output
     69 
     70 ```
     71 1
     72 -100
     73 ```