고흐의 연구실/자료구조와 알고리즘

백준 1476번 : 날짜 계산

전고흐 2018. 1. 12. 17:53
728x90




    
import java.util.Scanner;

public class a1476 {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int x=-1, y=0, z=0;
		
		while(true){
			while(true){
				x++;
				if((15*x+a)==(28*y+b))
					break;
				else if((15*x+a)>(28*y+b))
					y++;
			}
			if((28*y+b)>(19*z+c)){
				
				while(true){
					z++;
					if((28*y+b)<=(19*z+c))
						break;
				}
			}
			if((28*y+b)==(19*z+c))
				break;	
		}
		
		System.out.println(28*y+b);
	}
}


728x90