1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | import java.util.Scanner; import java.io.FileInputStream; class Solution { public static void main(String args[]) throws Exception { // Scanner sc = new Scanner(new FileInputStream("sample_input.txt")); Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] candidate = new int[n]; for (int i = 0; i < n; i++) { candidate[i] = sc.nextInt(); } int b = sc.nextInt(); int c = sc.nextInt(); long cnt = 0; for (int i = 0; i < n; i++) { cnt++; int remainder = (candidate[i] - b) % c; int exam_supervisor = (candidate[i] - b) / c; if (candidate[i] > b) { if (remainder == 0) cnt += exam_supervisor; else { if (exam_supervisor == 0) cnt += 1; else cnt += exam_supervisor + 1; } } } // for System.out.println(cnt); } // main } | cs |
'공부 > 알고리즘문제' 카테고리의 다른 글
백준 1260 DFS와 BFS (0) | 2017.04.15 |
---|---|
백준 1012 유기농 배추 (0) | 2017.04.13 |
백준 14499 주사위 굴리기 (0) | 2017.04.12 |
코드그라운드 시험 공부 (0) | 2017.04.11 |
코드그라운드 숫자 골라내기 (0) | 2017.04.11 |