Question
https://www.acmicpc.net/problem/25494
Algorithm
Code
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
private void solution() throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
StringBuilder sb = new StringBuilder();
while (t-->0) {
StringTokenizer st = new StringTokenizer(br.readLine());
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
int c = Integer.parseInt(st.nextToken());
int cnt = 0;
for (int i = 1; i <= a; i++) {
for (int j = 1; j <= b; j++) {
for (int k = 1; k <= c; k++) {
if (i%j==j%k && j%k==k%i && i%j==k%i) {
cnt++;
}
}
}
}
sb.append(cnt).append('\n');
}
System.out.println(sb);
}
public static void main(String[] args) throws Exception {
new Main().solution();
}
}
시간 복잡도
'Coding Test > [BAEKJOON] Java' 카테고리의 다른 글
| [BAEKJOON / Java] 10807. 개수 세기 (0) | 2025.12.07 |
|---|---|
| [BAEKJOON / Java] 10828. 스택 (0) | 2025.10.17 |
| [BAEKJOON / Java] 2292. 벌집 (0) | 2025.10.09 |
| [BAEKJOON / Java] 11650. 좌표 정렬하기 (0) | 2025.10.08 |
| [BAEKJOON / Java] 2884. 알람 시계 (0) | 2025.09.14 |