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
- 이분탐색
- 코딩테스트
- 건강
- 백준
- BOJ
- 시뮬레이션
- greedy
- SQL
- dfs
- 문자열
- 코테
- math
- 운동기록
- MySQL
- COS PRO
- 프로그래머스
- DP
- 러닝일지
- BFS
- 투포인터
- binary search
- 알고리즘
- 문제풀이
- SWEA
- oracle
- 자바
- priorityqueue
- 문제해결
- db
- Java
Archives
- Today
- Total
슈콩
[BOJ] 백준 1735 분자 합 본문
[문제]
https://www.acmicpc.net/problem/1735
[소스 코드]
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int a1 = Integer.parseInt(st.nextToken());
int b1 = Integer.parseInt(st.nextToken());
st = new StringTokenizer(br.readLine());
int a2 = Integer.parseInt(st.nextToken());
int b2 = Integer.parseInt(st.nextToken());
int a = a1*b2 + a2*b1;
int b = b1*b2;
int d = gcd(a,b);
System.out.println(a/d+" "+b/d);
}
private static int gcd(int a,int b) {
while(a!=0) {
int temp = a;
a = b%a;
b = temp;
}
return b;
}
}'Algorithms > Baekjoon' 카테고리의 다른 글
| [BOJ] 백준 1790 수 이어쓰기 2 (0) | 2025.09.11 |
|---|---|
| [BOJ] 백준 1747 소수&팰린드롬 (0) | 2025.09.11 |
| [BOJ] 백준 17103 골드바흐 파티션 (0) | 2025.09.10 |
| [BOJ] 백준 1676 팩토리얼 0의 개수 (0) | 2025.09.10 |
| [BOJ] 백준 15894 수학은 체육과목 입니다 (0) | 2025.09.10 |