Very cool Number
For a number X, let its "Coolness" be defined as the number of " 101 's occurring in its
binary representation.
For example, the number 21 has Coolness 2, since its binary representation is 18101,
and the string " 101 "occurs twice in this representation.
A number is defined as Very Cool if its Coolness is greater than or equal to K. Please,
output the number of Very Cool integers between 1 and R.
Input Two space-separated integers, R and K.
Dutput:
rint Single integer representing the number of Very Cool integers between 1 and R.
onstraints:
=K<=100
Answers
Answered by
4
Answer:
itne bade ramayan
Explanation:
mujhse nhi pade jate bhai
Answered by
0
Answer:
#include <bits/stdc++.h>
using namespace std;
int counter[100005];
int main()
{
for (int g=1; g<=100000; g++)
{
for (int y=0; y<20; y++)
{
if (((1<<y)&g) && (!((1<<(y+1))&g)) && ((1<<(y+2))&g))counter[g]++;
}
}
int T; scanf("%d", &T);
for (int g=0; g<T; g++)
{
int R,K;scanf("%d %d", &R, &K);
int ans=0;
for (int y=1; y<=R; y++)
{
ans+=(counter[y]>=K);
}
printf("%d\n", ans);
}
return 0;
}
Similar questions