justgo_developer

[JAVA] 백준 1094 막대기 본문

카테고리 없음

[JAVA] 백준 1094 막대기

다날92 2018. 1. 3. 19:58

import java.util.Scanner;


public class Main {

private static Scanner sc = new Scanner(System.in);

public static void main(String[] args) {

int bar = 64;

int x = sc.nextInt();

int cnt=0;

while(x!=0){

if(bar>x){

bar=bar/2;

}

else{

x=x-bar;

cnt++;

}

}

System.out.print(cnt);

}

}