Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

21.02.09 - [BOJ] 1475. 방 번호 #7

Closed
suhyunsim opened this issue Feb 14, 2021 · 0 comments
Closed

21.02.09 - [BOJ] 1475. 방 번호 #7

suhyunsim opened this issue Feb 14, 2021 · 0 comments
Assignees
Labels
성공 맞은 문제 실버 BOJ - 실버

Comments

@suhyunsim
Copy link
Owner

suhyunsim commented Feb 14, 2021

문제

핵심 아이디어

  • 각 숫자를 10으로 나눈 몫과 나머지를 활용해서 배열에 넣기
  • 6과 9는 중복 가능한걸로 계산
  • 배열의 max

어려운 점, 실수

  • 0일 때를 자꾸 빼먹음

풀이

package main.java.com.poogle.BOJ.Q1475;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] numbers = new int[10];
        while (n > 0) {
            numbers[n % 10] += 1;
            n /= 10;
        }

        int dup = numbers[6] + numbers[9];

        if ((numbers[6] + numbers[9]) % 2 == 1) {
            numbers[6] = dup / 2 + 1;
            numbers[9] = dup / 2 + 1;
        } else {
            numbers[6] = dup / 2;
            numbers[9] = dup / 2;
        }
        int max = 1;
        for (int i : numbers) {
            max = Math.max(i, max);
        }
        System.out.println(max);
    }
}
@suhyunsim suhyunsim self-assigned this Feb 14, 2021
@suhyunsim suhyunsim added this to the 2월 1주 차 milestone Feb 14, 2021
@suhyunsim suhyunsim added 실버 BOJ - 실버 구현 성공 맞은 문제 labels Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
성공 맞은 문제 실버 BOJ - 실버
Projects
None yet
Development

No branches or pull requests

1 participant