Advertisement
jeff69

Untitled

Dec 31st, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1.  
  2. #include "stdafx.h"
  3. #include <iostream>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7. long double h[100000000];
  8. int main(){
  9. double x;
  10. int f;
  11. cin >> f;
  12.  
  13. for (int i = 0; i < f; i++){
  14. cin >> h[i];
  15. }
  16.  
  17. for (int i = 0; i < f; i++){
  18. long double x = log(h[i]) / log(2);
  19.  
  20. long long y= floor(x)+1;
  21.  
  22. long long g = pow(2, y) - 1;
  23. long long s = h[i] * h[i] + h[i];
  24. long long v =s/2 - 2*g;
  25. cout << v << "\n";
  26. y = 0;
  27. g = 0;
  28. }
  29.  
  30.  
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement