Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 문제풀이
- 자바
- BFS
- 문제해결
- 문자열
- 코딩테스트
- SWEA
- BOJ
- 건강
- 프로그래머스
- db
- Java
- dfs
- binary search
- 백준
- 시뮬레이션
- oracle
- DP
- 이분탐색
- COS PRO
- MySQL
- priorityqueue
- 러닝일지
- 코테
- 운동기록
- 알고리즘
- SQL
- 투포인터
- greedy
- math
Archives
- Today
- Total
슈콩
[BOJ] 백준 1019 책 페이지 본문
[문제]
https://www.acmicpc.net/problem/1019
[소스 코드]
import java.io.*;
import java.util.*;
public class Main {
static int cnt =1;
static int[] num;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
num = new int[10];
int start = 1;
int end = n;
while(start<=end) {
while(start%10!=0 && start<=end) {
rangeOut(start);
start++;
}
if(start>end) break;
while(end%10!=9 && start<=end) {
rangeOut(end);
end--;
}
if(start>end) break;
start /= 10;
end /= 10;
for(int i=0;i<10;i++) {
num[i] += (end-start+1) * cnt;
}
cnt *= 10;
}
for(int i=0;i<10;i++) {
System.out.println(num[i]);
}
}
private static void rangeOut(int v) {
while(v>0) {
num[v%10] += cnt;
v /= 10;
}
}
}
'Algorithms > Baekjoon' 카테고리의 다른 글
| [BOJ] 백준 1038 감소하는 수 (0) | 2025.09.08 |
|---|---|
| [BOJ] 백준 10250 ACM 호텔 (0) | 2025.09.07 |
| [BOJ] 백준 1011 Fly me to the Alpha Centauri (0) | 2025.09.06 |
| [BOJ] 백준 11051 이항계수2 (0) | 2025.09.05 |
| [BOJ] 백준 6064 카잉 달력 (0) | 2025.09.05 |