View Code of Problem 3700

#include<stdio.h>
#include<math.h>
int main(){
	int a,p,t,y;
	char b[1000];
	while(scanf("%d",&a)!=EOF){
		if(a==0)break;
		p=0;
		while(a!=0){
			b[p]=a%2;
			a=a/2;
			p++;
		}
		for(int i=0;i<p;i++){
			if(b[i]==1){
				t=i;
				break;
			}
		}
		y=pow(2,t);
		printf("%d\n",y);
	}
}

Double click to view unformatted code.


Back to problem 3700