-
[SWEA-1946] 간단한 압축 풀기공부/SWEA 2022. 6. 8. 13:55728x90
https://swexpertacademy.com/main/code/problem/problemDetail.do
코드
import java.util.Scanner;public class swea1946 {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();System.out.println("#"+test_case);String a[]=new String[num];int arr[]=new int[num];int tot=0;for(int i=0;i<num;i++){a[i]=sc.next();arr[i]=sc.nextInt();tot+=arr[i];}String []str=new String[tot];int count=0;for(int i=0;i<num;i++){for(int j=0;j<arr[i];j++){str[count]=a[i];count++;}}for(int i=0;i<count;i++){if(i!=0&&i%10==0){System.out.println();}System.out.print(str[i]);}System.out.println();}}}728x90반응형'공부 > SWEA' 카테고리의 다른 글
[SWEA-1288] 새로운 불면증 치료법 - Java (0) 2022.06.10 [SWEA-1945] 간단한 소인수분해 - Java (0) 2022.06.09 [SWEA-1959] 두 개의 숫자열 - Java (0) 2022.06.08 [SWEA-1961] 숫자 배열 회전 - Java (0) 2022.06.07 [SWEA-1984] 중간 평균값 구하기 - Java (0) 2022.06.06