// lanqiao 2117 砍竹子 #include using namespace std; #define int long long signed main(){ int n; cin >> n; set pre; // 记录上一次竹子高度变化 int ans = 0; for(int i = 1; i <= n; i++){ int h; cin >> h; set 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 */