题库练习 Getting Zero
← 上一题 下一题 →

A15061 | Getting Zero

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Suppose you have an integer $v$ . In one operation, you can:

- either set $v = (v + 1) \bmod 32768$
- or set $v = (2 \cdot v) \bmod 32768$ .

You are given $n$ integers $a_1, a_2, \dots, a_n$ . What is the minimum number of operations you need to make each $a_i$ equal to $0$ ?

输入格式

The first line contains the single integer $n$ ( $1 \le n \le 32768$ ) — the number of integers.

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ( $0 \le a_i < 32768$ ).

输出格式

Print $n$ integers. The $i$ -th integer should be equal to the minimum number of operations required to make $a_i$ equal to $0$ .

输入输出样例

输入 #1
4
19 32764 10240 49
输出 #1
14 4 4 15
C++ 编辑器
输入
输出