CF1188D.Make Equal
NOI/NOI+/CTSC
通过率:0%
时间限制:4.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given n numbers a1,a2,…,an. In one operation we can add to any one of those numbers a nonnegative integer power of 2.
What is the smallest number of operations we need to perform to make all n numbers equal? It can be proved that under given constraints it doesn't exceed 1018.
给你 n 个数 a1,a2,…,an。在一次操作中,你可以给其中任意一个数加上一个非负整数次幂的 2(即形如 2k,其中 k≥0 的整数)。
你需要执行的最少操作次数是多少,才能使这 n 个数全部相等?在本题给定的约束条件下,可以证明答案不会超过 1018。
输入格式
The first line contains a single integer n (1≤n≤105).
The second line contains n integers a1,a2,…,an (0≤ai≤1017).
第一行包含一个整数 n(1≤n≤105)。
第二行包含 n 个整数 a1,a2,…,an(0≤ai≤1017)。
输出格式
Output exactly one integer — the smallest number of operations we need to perform to make all n numbers equal.
输出一个整数——使所有 n 个数相等所需的最少操作次数。
输入输出样例
输入#1
4 228 228 228 228
输出#1
0
输入#2
3 2 2 8
输出#2
3
说明/提示
In the first example, all numbers are already equal. So the needed number of operation is 0.
In the second example, we can apply the operation 3 times: add 8 to first 2, add 8 to second 2, add 2 to 8, making all numbers equal to 10. It can be proved that we can't make all numbers equal in less than 3 operations.
在第一个例子中,所有数字已经相等,因此所需的操作次数为 0。
在第二个例子中,我们可以执行 3 次操作:对第一个 2 加上 8,对第二个 2 加上 8,对 8 加上 2,使得所有数字都等于 10。可以证明,我们无法用少于 3 次操作使所有数字相等。
输入解题思路,AI测评打分。不知道怎么写?