27 lines
820 B
C++
27 lines
820 B
C++
// lanqiao 2117 砍竹子
|
||
#include<bits/stdc++.h>
|
||
using namespace std;
|
||
#define int long long
|
||
signed main(){
|
||
int n; cin >> n;
|
||
set<int> pre; // 记录上一次竹子高度变化
|
||
int ans = 0;
|
||
for(int i = 1; i <= n; i++){
|
||
int h; cin >> h;
|
||
set<int> cur; // 维护当前竹子的高度变化
|
||
while(h != 1){
|
||
cur.insert(h);
|
||
// 如果上一根竹子高度变化中没有h,则需要单独消耗一次操作
|
||
// 否则若相邻两根竹子在高度递减过程中存在高度相同的情况,则第二根竹子不需要重新计数,因为两根竹子一起砍就行了
|
||
if(!pre.count(h)) ans++;
|
||
h = sqrtl(h/2 + 1);
|
||
}
|
||
pre = cur;
|
||
}
|
||
cout << ans << endl;
|
||
return 0;
|
||
}
|
||
/* test samples -> 5
|
||
6
|
||
2 1 4 2 6 7
|
||
*/ |