개발자 톡

연습문제 톡 [21년 재직자 대회 예선] 전광판

반례좀 부탁드려요 정답과비교했을때 답이 다 같아서요 ㅠ

등록일
2024-12-12 07:49:45
조회수
121
작성자
qpfl1010

import java.util.Scanner;


public class Mainb {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int N = sc.nextInt();

int[][] temp = new int[N][2];

int[][] a = new int[11][11];



a[0][0] = 0;

a[0][1] = 4;a[1][0] = 4;

a[0][2] = 3;a[2][0] = 3;

a[0][3] = 2;a[3][0] = 2;

a[0][4] = 4;a[4][0] = 4;

a[0][5] = 3;a[5][0] = 3;

a[0][6] = 2;a[6][0] = 2;

a[0][7] = 2;a[7][0] = 2;

a[0][8] = 1;a[8][0] = 1;

a[0][9] = 2;a[9][0] = 2;


a[1][2] = 5;a[2][1] = 5;

a[1][3] = 3;a[3][1] = 3;

a[1][4] = 2;a[4][1] = 2;

a[1][5] = 5;a[5][1] = 5;

a[1][6] = 6;a[6][1] = 6;

a[1][7] = 2;a[7][1] = 2;

a[1][8] = 5;a[8][1] = 5;

a[1][9] = 4;a[9][1] = 4;


a[2][3] = 2;a[3][2] = 2;

a[2][4] = 5;a[4][2] = 5;

a[2][5] = 4;a[5][2] = 4;

a[2][6] = 3;a[6][2] = 3;

a[2][7] = 5;a[7][2] = 5;

a[2][8] = 2;a[8][2] = 2;

a[2][9] = 3;a[9][2] = 3;


a[3][4] = 4;a[4][3] = 4;

a[3][5] = 2;a[5][3] = 2;

a[3][6] = 3;a[6][3] = 3;

a[3][7] = 3;a[7][3] = 3;

a[3][8] = 2;a[8][3] = 2;

a[3][9] = 1;a[9][3] = 1;


a[4][5] = 3;a[5][4] = 3;

a[4][6] = 4;a[6][4] = 4;

a[4][7] = 2;a[7][4] = 2;

a[4][8] = 3;a[8][4] = 3;

a[4][9] = 2;a[9][4] = 2;


a[5][6] = 1;a[6][5] = 1;

a[5][7] = 3;a[7][5] = 3;

a[5][8] = 2;a[8][5] = 2;

a[5][9] = 1;a[9][5] = 1;


a[6][7] = 4;a[7][6] = 4;

a[6][8] = 1;a[8][6] = 1;

a[6][9] = 2;a[9][6] = 2;


a[7][8] = 3;a[8][7] = 3;

a[7][9] = 2;a[9][7] = 2;


a[8][9] = 1;a[9][8] = 1;


a[10][0]=6;a[0][10]=6;

a[10][1]=2;a[1][10]=2;

a[10][2]=5;a[2][10]=5;

a[10][3]=5;a[3][10]=5;

a[10][4]=4;a[4][10]=4;

a[10][5]=5;a[5][10]=5;

a[10][6]=6;a[6][10]=6;

a[10][7]=4;a[7][10]=4;

a[10][8]=7;a[8][10]=7;

a[10][9]=6;a[9][10]=6;

a[10][10]=0;


int[] a1 = new int[5];

int[] a2 = new int[5];


for(int i=0;i<N;i++){

temp[i][0] = sc.nextInt();

temp[i][1] = sc.nextInt();

}

int[] r = new int[N];

for(int i=0;i<N;i++){

int result = 0;

String s1 = String.valueOf(temp[i][0]);

String s2 = String.valueOf(temp[i][1]);

for(int j=0;j<5;j++){

a1[j] = temp[i][0]%10;

temp[i][0] = temp[i][0]/10;


a2[j] = temp[i][1]%10;

temp[i][1] = temp[i][1]/10;

if(j+1>s1.length()){

a1[j] = 10;

}

if(j+1>s2.length()){

a2[j] = 10;

}

//System.out.println("a1[j]a2[j] = "+a1[j]+"/"+a2[j]);

result = result + a[a1[j]][a2[j]];

}

r[i] = result;

}



for(int i=0;i<N;i++) {

System.out.println(r[i]);

}


}

}

#[21년_재직자_대회_예선]_전광판

이 카테고리의 톡 더보기