Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

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

From ZeroWiki
No edit summary
 
(Repair batch-0004 pages from live compare)
 
Line 28: Line 28:
  printf("output : %d\n", input);
  printf("output : %d\n", input);
  }
  }

Latest revision as of 00:37, 27 March 2026

데블스캠프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);
}