Posts

Showing posts from 2021

A. Arithmetic Array 1537A

A. Arithmetic Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output An array  b b  of length  k k  is called good if its arithmetic mean is equal to  1 1 . More formally, if b 1 + ⋯ + b k k = 1. b 1 + ⋯ + b k k = 1. Note that the value  b 1 + ⋯ + b k k b 1 + ⋯ + b k k  is not rounded up or down. For example, the array  [ 1 , 1 , 1 , 2 ] [ 1 , 1 , 1 , 2 ]  has an arithmetic mean of  1.25 1.25 , which is not equal to  1 1 . You are given an integer array  a a  of length  n n . In an operation, you can append a  non-negative  integer to the end of the array. What's the minimum number of operations required to make the array good? We have a proof that it is always possible with finitely many operations. Input The first line contains a single integer  t t  ( 1 ≤ t ≤ 1000 1 ≤ t ≤ 1000 ) — the number of test cases. Then  t t  test case...