返回题解分享
讨论 / 题解分享/ 帖子详情

砍竹子(编程题) - 题解

#include <bits/stdc++.h>
using namespace std;

#define int long long

const int N = 2e5 + 10;

vector<unordered_set<int>> hs;
int ans;
int n;

signed main(){
  cin >> n;
  hs.resize(n + 1);


  for(int i = 1; i <= n; ++i){
    int x;
    cin >> x;
    while(x > 1){
    if(!hs[i-1].count(x)) ++ans;
    hs[i].insert(x);
    x = sqrt(x / 2 + 1);
  }
}

  cout << ans << endl;

  return 0;

}




0 回复 0 转发 0 喜欢 5 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!