fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4.  
  5. signed main() {
  6. int n = 6174, res = 0;
  7. for (int i = 0; (1LL << i) <= n; i++) {
  8. int x = n / (1LL << i);
  9. int k = (x + 1) / 2;
  10. res += k * k;
  11. }
  12. cout << res << '\n';
  13. }
Success #stdin #stdout 0.01s 5376KB
stdin
Standard input is empty
stdout
12708024