Сколько целых чисел из отрезка [27, 53][27,53] содержат в своей двоичной записи не менее трех значащих нулей?

hcg1 hcg1    3   14.05.2020 13:17    21

Ответы
Стаилз2002 Стаилз2002  14.10.2020 18:27

ответ: 15

Прога:

/** libraries */

#include <iostream>

#include <cmath>

#include <vector>

#include <map>

#include <set>

#include <queue>

#include <stack>

#include <algorithm>

/** libraries */

using namespace std;

/** defines */

#define ll long long

#define ld long double

#define yes cout << "YES" << "\n"

#define no cout << "NO" << "\n"

/** defines */

ll f(ll num){

   ll res = 0;

   while(num > 0){

       res += 1 - num % 2;

       num /= 2;

   }

   return res;

}

signed main() {

   ios_base::sync_with_stdio(false);

   cin.tie(nullptr);

   cout.tie(nullptr);

   ll ans = 0;

   for(ll i = 27; i <= 53; i++)

       if(f(i) >= 3)

           ans++;

   cout << ans;

}

ПОКАЗАТЬ ОТВЕТЫ
Другие вопросы по теме Информатика