백준 #27590번 Sun and Moon

jhj·2024년 3월 3일

백준 JAVA

목록 보기
436/583
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int ds = sc.nextInt();
		int ys = sc.nextInt();
		int dm = sc.nextInt();
		int ym = sc.nextInt();
		
		int s = ys - ds;
		int m = ym - dm;
		
		while(s != m) {
			if(s < m) {
				s += ys;
			}else {
				m += ym;
			}
		}
		System.out.println(s);
		sc.close();
	}
}
profile
개발자를 꿈꾸는

0개의 댓글