슈콩

[SWEA] 유효기간 본문

Algorithms/SWEA

[SWEA] 유효기간

shukong 2025. 11. 18. 15:05

 

 

 

[문제]

https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AXK6YRNaKq0DFAU3

 

 

 

[소스 코드]

import java.io.*;
import java.util.*;
public class Solution {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		int T = Integer.parseInt(br.readLine());
		for(int tc=1;tc<=T;tc++) {
			String card = br.readLine();
			String a = card.substring(0,2);
			String b = card.substring(2);
			boolean front = check(a);
			boolean back = check(b);
			String result = "NA";
			if(front && back) result = "AMBIGUOUS";
			else if(front) result = "MMYY";
			else if(back) result = "YYMM";
			System.out.println("#"+tc+" "+result);
		}
	}
	private static boolean check(String s) {
		int num = Integer.valueOf(s);
		if(num>=1 && num<=12) return true;
		return false;
	}
}

'Algorithms > SWEA' 카테고리의 다른 글

[SWEA] 극장 좌석  (0) 2025.11.18
[SWEA] 명진이와 동휘의 숫자 맞추기  (0) 2025.11.18
[SWEA] 홀수일까 짝수일까  (0) 2025.11.17
[SWEA] 계산기  (0) 2025.11.17
[SWEA] 반반  (0) 2025.11.17