Given an integer, , find each such that:
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
long int solve(long int n) {
// Complete this function)
long count =0;
while (n>0)
{
if (n%2==0)
{ count++;}
n=n>>1;
}
//printf("%d",count) ;
unsigned long int q=1;
return (q<<count);
}
int main() {
long int n;
scanf("%li", &n);
long int result = solve(n);
printf("%ld\n", result);
return 0;
}
Input Format
A single integer, .
Constraints
- for of the maximum score.
Output Format
Print the total number of integer 's satisfying both of the conditions specified above.
Sample Input 0
For , the values and satisfy the conditions:
Sample Input 1
For , the values , , , and satisfy the conditions:
Sample Input 0
5
Sample Output 02
Explanation 0For , the values and satisfy the conditions:
Sample Input 1
10
Sample Output 14
Explanation 1For , the values , , , and satisfy the conditions:
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
long int solve(long int n) {
// Complete this function)
long count =0;
while (n>0)
{
if (n%2==0)
{ count++;}
n=n>>1;
}
//printf("%d",count) ;
unsigned long int q=1;
return (q<<count);
}
int main() {
long int n;
scanf("%li", &n);
long int result = solve(n);
printf("%ld\n", result);
return 0;
}
No comments:
Post a Comment