-
https://www.acmicpc.net/problem/1475
1475번: 방 번호
첫째 줄에 다솜이의 방 번호 N이 주어진다. N은 1,000,000보다 작거나 같은 자연수이다.
www.acmicpc.net
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s = br.readLine(); s= s.replace('9','6'); int N = s.length(); int a[] = new int [9]; for(int i=0; i<N;i++) { int number = s.charAt(i)-'0'; a[number]++; } if(a[6]!=0) { a[6] = Math.round(a[6]/2.0f); } int max =0; for(int i=0; i<9;i++) { max = Math.max(a[i], max); } System.out.println(max); } }
참고 자료 :
https://youjourney.tistory.com/42
[백준] 방 번호 (1475)(java)
원본 문제 : https://www.acmicpc.net/problem/1475 문제 다솜이는 은진이의 옆집에 새로 이사왔다. 다솜이는 자기 방 번호를 예쁜 플라스틱 숫자로 문에 붙이려고 한다. 다솜이의 옆집에서는 플라스틱 숫
youjourney.tistory.com
'백준 > 구현' 카테고리의 다른 글
11721 열 개씩 끊어 출력하기 (0) 2021.10.18 7568 덩치 (0) 2021.10.18 10773 제로 (0) 2021.10.18 2563 색종이 (0) 2021.10.18 1292 쉽게 푸는 문제 (0) 2021.10.18