fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int Mod=998244353;
  5.  
  6. void solve() {
  7.  
  8. ll n;
  9. cin >> n;
  10. ll ans=0;
  11. while(n){
  12. ans+=n;
  13. n/=2;
  14. }
  15. cout << ans << '\n';
  16. }
  17.  
  18. int main(){
  19. ios::sync_with_stdio(false);
  20. cin.tie(nullptr);
  21.  
  22. int t;
  23. cin >> t;
  24. while (t--) solve();
  25.  
  26.  
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0.01s 5324KB
stdin
6
3
10
37
1
10000000000000000
15
stdout
4
18
71
1
19999999999999980
26