andy6804tw
6/14/2017 - 11:00 AM

Main2.java

import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int num = scn.nextInt();
		while(num-->0){
			int a = scn.nextInt(), b = scn.nextInt() , c = scn.nextInt();
			for(int i=b;;i++){
				if((i-a)%7 == 0 && (i+b)%11 == 0 && (i-c)%17 == 0){
					System.out.println(i);
					break;
				}
			}
		}
	}

}