Сколько целых чисел из отрезка [27, 53][27,53] содержат в своей двоичной записи не менее трех значащих нулей?
Ответы на вопрос
Ответил glestych
0
Ответ: 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;
}
Новые вопросы