본문 바로가기

Algorithm/SWEA

[SWEA] 1946. 간단한 압축풀기 D2 JAVA

반응형


문제 이해

 

아이디어

 

코드

import java.io.*;
import java.util.*;
public class Solution {

	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		StringBuilder sb= new StringBuilder();
		
		int T= stoi(br.readLine());
		
		for(int tc=1;tc<=T;++tc) {
			int N = stoi(br.readLine());
			int cnt =0;
			sb.append("#").append(tc).append('\n');
			for(int i=0;i<N;++i) {
				st= new StringTokenizer(br.readLine()," ");
				String word = st.nextToken();
				int val = stoi(st.nextToken());
				for(int j=0;j<val;++j) {
					sb.append(word);
					cnt++;
					if(cnt >=10) {
						sb.append('\n');
						cnt=0;
					}
				}
			}
			sb.append('\n');
		}
		System.out.println(sb);
	}
	
	static int stoi(String s) {
		return Integer.parseInt(s);
	}
}

 

 


 

 

집사는개발자가되고파

 

choppadontbiteme.tistory.com

 

반응형