[SWEA] 영준이와 신비한 뿔의 숲

문제 보러가기

제한사항

두 정수 n, m의 범위는 (1 ≤ n ≤ 300, m ≤ n ≤ 2m) 이다.

첫번째 생각

M마리라고 가정했을 때, M*2-N을 한다면 유니콘의 숫자가 나올 것이다.

그렇다면 트윈혼의 숫자는 M - (M*2-N) 이 된다.

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
import java.util.Scanner;

public class Solution {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		for(int tc=1; tc<=T; tc++) {
			int N = sc.nextInt();
			int M = sc.nextInt();
			System.out.println("#"+tc+" "+(M*2-N)+" "+(M-(M*2-N)));
		}
	}
}