Notice
Recent Posts
Recent Comments
Link
개발 공부~
[백준 - 4796] 캠핑 .java 본문
https://www.acmicpc.net/problem/4796
- L, P, V 세 값이 모두 0이면 입력이 끝났다는 뜻 → 프로그램 종료
- 문제를 이해하기 어렵게 적음
- 총 휴가 일수: V일
- 휴가의 반복 주기: P일
- 그 P일 중에서 캠핑장을 사용할 수 있는 날: L일
- v/p가 주기 -> 주기 * l
- 나머지는 v%p 일이지만 나머지와 l중에 작은값이 되어야함
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int cnt = 0;
while(true) {
StringTokenizer st = new StringTokenizer(br.readLine());
int l = Integer.parseInt(st.nextToken());
int p = Integer.parseInt(st.nextToken());
int v = Integer.parseInt(st.nextToken());
if(l==0 || p==0 || v==0) break;
int answer = (v/p) * l + Math.min(l, v%p);
cnt++;
System.out.println("Case "+cnt+": "+answer);}
}
}'코딩테스트 > 백준' 카테고리의 다른 글
| [백준 - 15652] N과 M (4) .java (0) | 2025.11.16 |
|---|---|
| [백준 - 15650] N과 M (2) .java (0) | 2025.11.16 |
| [백준 - 13305] 주유소 .java (0) | 2025.11.15 |
| [백준 - 15903] 카드 합체 놀이 .java (0) | 2025.11.12 |
| [백준 - 2437] 저울 .java (0) | 2025.11.11 |