CF1188D.Make Equal
普及/提高-
通过率:0%
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 .
输入格式
The first line contains a single integer n ( 1≤n≤105 ).
The second line contains n integers 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.
输入输出样例
输入#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.