-
[SWEA-1979] 어디에 단어가 들어갈 수 있을까 - Java공부/SWEA 2022. 6. 2. 16:39728x90
https://swexpertacademy.com/main/code/problem/problemDetail.do
코드
import java.util.Scanner;public class swea1979 {public static void main(String args[]) throws Exception{Scanner sc = new Scanner(System.in);int T;T=sc.nextInt();for(int test_case = 1; test_case <= T; test_case++){int num=sc.nextInt();int num2=sc.nextInt();int arr[][]=new int[num][num];for(int i=0;i<num;i++){for(int j=0;j<num;j++){arr[i][j]=sc.nextInt();}}int answer=0;for(int i=0;i<num;i++){int count=0;for(int j=0;j<num;j++){if(arr[i][j]==1){count++;}else{if(count==num2){answer++;}count=0;}}if(count==num2){answer++;}}for(int i=0;i<num;i++){int count=0;for(int j=0;j<num;j++){if(arr[j][i]==1){count++;}else{if(count==num2){answer++;}count=0;}}if(count==num2){answer++;}}System.out.println("#"+test_case+" "+answer);}}}728x90반응형'공부 > SWEA' 카테고리의 다른 글
[SWEA-1970] 쉬운 거스름돈 - Java (0) 2022.06.02 [SWEA-1976] 시각 덧셈 - Java (0) 2022.06.02 [SWEA-1986] 지그재그 숫자 - Java (0) 2022.06.01 [SWEA-1989] 초심자의 회문 검사 - Java (0) 2022.06.01 [SWEA-2001] 파리 퇴치 -Java (0) 2022.06.01