1. 그냥 단순하게 M 번 돌리면 된다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.io.*; | |
/** | |
* https://www.acmicpc.net/problem/11944 | |
* BOJ 백준온라인져지 11944 NN 풀이 | |
*/ | |
public class Main { | |
private static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); | |
public static void main (String args[]) throws IOException { | |
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | |
String str1[] = br.readLine().split(" "); | |
int N = Integer.parseInt(str1[0]); | |
int M = Integer.parseInt(str1[1]); | |
for (int i = 0; i < N; i++) { | |
for (int j = 0; j < str1[0].length(); j++) { | |
if (M == 0) { | |
i = N; | |
break; | |
} | |
bw.write(str1[0].charAt(j)); | |
M--; | |
} | |
} | |
bw.flush(); | |
} | |
} |
문제
문제는 매우 간단하다. N을 N번 출력하는 프로그램을 작성하여라. 다만, 답이 길어지는 경우 답의 앞 M자리만 출력한다.
입력
첫 번째 줄에는 N, M이 주어진다. (1 ≤ N, M ≤ 2016)
출력
N을 N번 출력한다. 만약 답이 길어지면 답의 앞 M자리를 출력한다.
'IT > 알고리즘' 카테고리의 다른 글
BOJ 백준온라인져지 11945 뜨거운 붕어빵 풀이 (0) | 2018.04.30 |
---|---|
BOJ 백준온라인져지 11943 파일 옮기기 풀이 (0) | 2018.04.30 |
BOJ 백준온라인져지 1194 달이 차오른다, 가자. 풀이 (0) | 2018.04.26 |
BOJ 백준온라인져지 2559 수열 풀이 (0) | 2018.04.25 |
BOJ 백준온라인져지 12845 모두의 마블 풀이 (0) | 2018.04.25 |