Dev.baelanche

[백준 9550] 아이들은 사탕을 좋아해 본문

Data Structure & Algorithm/PS - JAVA

[백준 9550] 아이들은 사탕을 좋아해

baelanche 2019. 4. 19. 21:49
반응형

 

 

아이들에게는 k 만큼 반드시 주어야 하므로

사탕 개수 / k 를 카운트하면 된다.

 

 

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int t = sc.nextInt();
        
        while(t-->0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            int cnt = 0;
            while(n-->0) {
                int a = sc.nextInt();
                cnt += a/k;
            }
            System.out.println(cnt);
        }
    }
}
반응형

'Data Structure & Algorithm > PS - JAVA' 카테고리의 다른 글

[백준 3049] 다각형의 대각선  (0) 2019.04.19
[백준 11006] 남욱이의 닭장  (0) 2019.04.19
[백준 2965] 캥거루 세마리  (0) 2019.04.19
[백준 2921] 도미노  (0) 2019.04.19
[백준 10569] 다면체  (0) 2019.04.19
Comments