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
- 프로그래머스
- MySQL
- DP
- binary search
- 자바
- priorityqueue
- 시뮬레이션
- 문제해결
- 문제풀이
- 문자열
- SWEA
- 알고리즘
- 건강
- dfs
- greedy
- 코테
- SQL
- BFS
- 러닝일지
- COS PRO
- 투포인터
- 운동기록
- Java
- 백준
- 코딩테스트
- 이분탐색
- oracle
- BOJ
- db
- math
Archives
- Today
- Total
슈콩
[BOJ] 백준 2312 수 복원하기 본문
[문제]
https://www.acmicpc.net/problem/2312
[소스 코드]
import java.io.*;
import java.util.*;
public class Main {
static boolean[] prime = new boolean[100001];
static List<Integer> list = new ArrayList<>();
public static void main(String[] args) throws IOException {
isPrime();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
while(t-->0) {
int n = Integer.parseInt(br.readLine());
for(int i : list) {
int cnt = 0;
while(n%i==0) {
cnt++;
n /= i;
}
if(cnt!=0) {
System.out.println(i+" "+cnt);
}
}
}
}
private static void isPrime() {
Arrays.fill(prime, true);
prime[1] = false;
for(int i=2;i*i<=100000;i++) {
if(!prime[i]) continue;
for(int j=i*i;j<=100000;j+=i) {
prime[j] = false;
}
}
for(int i=2;i<=100000;i++) {
if(prime[i]) list.add(i);
}
}
}'Algorithms > Baekjoon' 카테고리의 다른 글
| [BOJ] 백준 2869 달팽이는 올라가고 싶다 (0) | 2025.09.13 |
|---|---|
| [BOJ] 백준 2839 설탕 배달 (0) | 2025.09.12 |
| [BOJ] 백준 2292 벌집 (0) | 2025.09.12 |
| [BOJ] 백준 2089 -2진수 (0) | 2025.09.12 |
| [BOJ] 백준 2004 조합 0의 개수 (0) | 2025.09.12 |