백준 19947 투자의 귀재 배주형 [Java]

빨대씹는버릇있음·2023년 3월 20일

백준 실버

목록 보기
9/25


import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		
		String s = br.readLine();
		StringTokenizer st = new StringTokenizer(s);
		int h = Integer.parseInt(st.nextToken());
		int y = Integer.parseInt(st.nextToken());
		
		
		long [] dp = new long[11];
		dp[0] = h;
		
		for(int i=1; i<=y; i++) {
			dp[i] = (long)Math.floor(dp[i-1]*1.05);
			
			if(i >= 3) dp[i] = Math.max((long)Math.floor(dp[i-3]*1.2), dp[i]);   
			if(i >= 5) dp[i] = Math.max((long)Math.floor(dp[i-5]*1.35), dp[i]);  
		}
		
		System.out.println(dp[y]);
				
	}
}

2023-03-20

0개의 댓글