Advertisement
deushiro

Untitled

Mar 10th, 2020
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     double a = 0, b = 0;
  8.     string s = "B6DB6DB6DB6D";
  9.     reverse(s.begin(), s.end());
  10.     for(int i = 0; i < s.size(); ++i){
  11.         int x;
  12.         if(s[i] > '0' && s[i] <= '9'){
  13.             x = s[i] - '0';
  14.         }
  15.         else
  16.             x = s[i] - 'A' + 10;
  17.         a += x * pow(16, i - 12);
  18.     }
  19.     b = 10 * pow(16, -1);
  20.     double c = a / b;
  21.     c -= 1;
  22.     int ans = 1;
  23.     for(int i = 0; i < 1000; ++i){
  24.         c *= 2;
  25.         if(floor(c) == 1){
  26.             ++ans;
  27.         }
  28.         if(c == 0){
  29.             break;
  30.         }
  31.         if(c >= 1){
  32.             c -= floor(c);
  33.         }
  34.     }
  35.     cout << ans << endl;
  36. }
  37.  
  38.  
  39. //B6DB6DB6DB6D
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement