Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- double a = 0, b = 0;
- string s = "B6DB6DB6DB6D";
- reverse(s.begin(), s.end());
- for(int i = 0; i < s.size(); ++i){
- int x;
- if(s[i] > '0' && s[i] <= '9'){
- x = s[i] - '0';
- }
- else
- x = s[i] - 'A' + 10;
- a += x * pow(16, i - 12);
- }
- b = 10 * pow(16, -1);
- double c = a / b;
- c -= 1;
- int ans = 1;
- for(int i = 0; i < 1000; ++i){
- c *= 2;
- if(floor(c) == 1){
- ++ans;
- }
- if(c == 0){
- break;
- }
- if(c >= 1){
- c -= floor(c);
- }
- }
- cout << ans << endl;
- }
- //B6DB6DB6DB6D
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement