반응형
SMALL
문제 정보
문제명 - Fill the Rowboats
난이도 - 브론즈 IV
문제 번호 - 5300번
문제 링크
https://www.acmicpc.net/problem/5300
5300번: Fill the Rowboats!
The output will be the number of each pirate separated by spaces, with the word ”Go!” after every 6th pirate, and after the last pirate.
www.acmicpc.net
문제
Captain Jack decides to to take over a rival’s ship. He needs to send his henchmen over on rowboats that can hold 6 pirates each. You will help him count out pirates in groups of 6. The last rowboat may have fewer than 6 pirates. To make your task easier each pirate has been assigned a number from 1 to N.
입력
The input will be N, the number of pirates you need to send over on rowboats.
출력
The output will be the number of each pirate separated by spaces, with the word ”Go!” after every 6th pirate, and after the last pirate.
예제 입력/출력
예제 입력 예제 출력 10
1 2 3 4 5 6 Go! 7 8 9 10 Go!
18
1 2 3 4 5 6 Go! 7 8 9 10 11 12 Go! 13 14 15 16 17 18 Go!
알고리즘 분류
● 구현
소스코드
package Lv1_Bronze;
import java.io.*;
/**
* @author HanHoon
* @category 구현
* https://www.acmicpc.net/problem/5300
*/
public class BOJ_B4_5300_Fill_the_Rowboats {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder str = new StringBuilder();
// N
int N = Integer.parseInt(br.readLine());
for (int n = 1; n <= N; n++){
str.append(n + " ");
if(n%6 == 0 || n == N)
str.append("Go! ");
}
System.out.print(str);
br.close();
}
}
BaekJoon List
BaekJoon List
BOJ Start!! ● [BOJ] 백준 회원가입, 시작하는 법 ● [BOJ] 등급(티어) 및 Solved.AC 적용 ● [BOJ/JAVA] 백준 소스코드 제출 시 유의사항(자바) Bronze ● Bronze V - ● Bronze IV - ● Bronze III -..
han-hoon.tistory.com
기회는 준비된 자에게 찾아온다.
![](https://t1.daumcdn.net/keditor/emoticon/friends1/large/014.gif)
반응형
LIST
'BaekJoon > Bronze' 카테고리의 다른 글
[BOJ/JAVA] 백준 1718 : 암호 (자바) (2) | 2023.10.20 |
---|---|
[BOJ/JAVA] 백준 7891 : Can you add this? (자바) (0) | 2023.10.20 |
[BOJ/JAVA] 백준 1681 : 줄 세우기 (자바) (0) | 2023.10.17 |
[BOJ/JAVA] 백준 1453 : 피시방 알바 (자바) (0) | 2023.08.23 |
[BOJ/JAVA] 백준 1440 : 타임머신 (자바) (0) | 2023.08.22 |
댓글