알고리즘/SwExpert recipe

[SWEA] 준홍이의카드놀이 D3

컵라면만두세트 2021. 3. 25. 00:02
package D3;

import java.util.Scanner;

public class 준홍이의카드놀이 {
	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();
//			int arr[] = new int[N+1];
//			int arr2[] = new int[M+1];
			int cnt[] = new int[N+M+1];
			
			for(int i =1; i<=N; i++) {
				for(int j =1; j<=M; j++) {
					cnt[i+j]++;
				}
			}
			int max = 0; 
			for(int i =2; i<N+M; i++) {
				if(cnt[i]>max) {
					max = Math.max(cnt[i], max) ;
				}
			}
			System.out.print("#" + tc + " " );
			for(int i=2; i<=M+N; i++) {
				if(cnt[i] == max)
					System.out.print(i + " ");
			}
			System.out.println();
		}
	}

}

'알고리즘 > SwExpert recipe' 카테고리의 다른 글

[SWEA] 직사각형 길이 찾기 [D3]  (0) 2021.03.29
[SWEA] 사람 네트워크 D6  (0) 2021.03.25
[SWEA] 동철이의 프로그래밍 대회 D3  (0) 2021.03.20
[SWEA] String D3  (0) 2021.03.20
[SWEA] 석찬이의 받아쓰기 D3  (0) 2021.03.18