-
[Softeer] 전광판 (lv.2)ALGORITHM/SWEXPERT|SOFTEER 2022. 1. 16. 22:45
https://softeer.ai/practice/info.do?eventIdx=1&psProblemId=624&sw_prbl_sbms_sn=42285
2021-01-16
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.StringTokenizer;public class Main624 {public static int[][] arr = {{1, 1, 1, 0, 1, 1, 1},{0, 0, 1, 0, 0, 0, 1},{0, 1, 1, 1, 1, 1, 0},{0, 1, 1, 1, 0, 1, 1},{1, 0, 1, 1, 0, 0, 1},{1, 1, 0, 1, 0, 1, 1},{1, 1, 0, 1, 1, 1, 1},{1, 1, 1, 0, 0, 0, 1},{1, 1, 1, 1, 1, 1, 1},{1, 1, 1, 1, 0, 1, 1}};public static int T;public static String A, B;public static int minus (int a, int b) {int count = 0;if(a >= 0 && b >= 0) {for(int i = 0; i < 7; i++) if(arr[a][i] != arr[b][i]) count++;} else for(int j = 0; j < 7; j++) count += arr[a][j];return count;}public static void main(String[] args) throws IOException {BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));StringTokenizer st = new StringTokenizer(bf.readLine());T = Integer.parseInt(st.nextToken());for(int ts = 1; ts <= T; ts++) {st = new StringTokenizer(bf.readLine());A = st.nextToken();B = st.nextToken();int answer = 0;int alen = A.length() - 1;int blen = B.length() - 1;while(true) {if(alen < 0 && blen < 0) break;if(alen >= 0 && blen >= 0) answer += minus(Character.getNumericValue(A.charAt(alen)), Character.getNumericValue(B.charAt(blen)));else if(alen < 0) answer += minus(Character.getNumericValue(B.charAt(blen)), -1);else if(blen < 0) answer += minus(Character.getNumericValue(A.charAt(alen)), -1);alen--;blen--;}System.out.println(answer);}}}cs 'ALGORITHM > SWEXPERT|SOFTEER' 카테고리의 다른 글
[Softeer] 비밀메뉴 (lv.2) (0) 2022.01.16 [Softeer] 택배 마스터 광우 (lv.3) (0) 2021.11.02 [Softeer] 스마트 물류 (lv.3) (0) 2021.11.02 [Softeer] 동계 테스트 시점 예측 (lv.3) (0) 2021.11.02 [Softeer] GBC (lv.2) (0) 2021.11.02