데블스캠프2009/금요일/연습문제/ACM2453/송지원

  • 78, 83일땐 잘나오는데 정작 1일때 안됨..;; 난줴 고쳐야겠


#include <iostream>
int main(){
	int input, i=2, b=1, count=0, temp = 0;
	scanf("%d", &input);
	if(input == 0) return 0;
	temp = input;
	while(1){
		if(input%2 == 1) break;
		temp >>= 1;
		if(temp %2 == 1) break;	
		b++;
	}
	printf("b = %d, i = %d\n", b, i);

	printf("temp : %d\n", temp);
	for(;1;count++, temp >>= 1)
		if(temp %2 == 0) break;
	printf("count : %d\n", count);
	input = ((input >> b+count) + 1);
	input <<= b+1;
	for(i=0; i<count-b; i++){
		input <<= 1;
		input++;
	}
	printf("output : %d\n", input);
}
Retrieved from http://wiki.zeropage.org/wiki.php/데블스캠프2009/금요일/연습문제/ACM2453/송지원
last modified 2021-02-07 05:29:08