| 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 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
													
											
												
												- anr
- 컬렉션
- support fragment
- 안드로이드 DBMS
- android fragment
- 알고리즘
- 소수
- 너비우선탐색
- java
- 소수 알고리즘
- 백준 알고리즘
- support 라이브러리
- 자료구조
- 안드로이드 AdapterView
- Github
- android adapterview
- 자바 컬렉션
- DFS
- BFS
- 안드로이드
- SQLite와 Realm 차이점
- oracle
- 깊이우선탐색
- 안드로이드 파일
- db
- application not responding
- 백준
- 안드로이드 ANR
- 액티비티 ANR
- android support
													Archives
													
											
												
												- Today
- Total
밍의 기록들😉
[문제] 분수 합 1735번 본문
https://www.acmicpc.net/problem/1735
public class FractionSum {
	public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a_n = scan.nextInt(); 
        int a_d = scan.nextInt();
        int b_n = scan.nextInt(); 
        int b_d = scan.nextInt();
       int d = a_d * b_d;
       a_n = a_n * b_d;
       b_n = b_n *a_d;
       
       int n = a_n +b_n;
       
       int gcd_num = gcd(n,d);
       n = n/gcd_num;
       d = d/gcd_num;
       System.out.println(n +" "+d);
	}
	private static int gcd(int a, int b) {
		if(b==0){
			return a;
		}
		else{
			return gcd(b, a%b);
		}
	}'자료구조, 알고리즘 > 문제풀이' 카테고리의 다른 글
| [문제] 웜바이러스 2606번 (0) | 2018.09.05 | 
|---|---|
| [문제] 이진 패턴 (0) | 2018.09.04 | 
| [문제] 자연수의 분할 (4) | 2018.09.04 | 
| [문제] 단지번호 붙이기 2667번 (0) | 2018.08.27 | 
| [문제] 가로수 2485번 (0) | 2018.08.16 | 
			  Comments
			
		
	
               
           
					
					
					
					
					
					
				