세균 증식

난이도 최하
화낼거양's avatar
Dec 04, 2024
세균 증식
Contents
문제정답
 
 
 

문제

 
 
notion image
 
기본적으로 주어진 코드 :
class Solution { public int solution(int n, int t) { int answer = 0; return answer; } }
 

정답

 
class Solution { public int solution(int n, int t) { int answer = n; for (int i = 0; i < t; i++) { answer *= 2; } return answer; } }
 
  • t 의 값이 1 증가할 때마다 반환값을 2배로 늘려야 합니다.
  • t 값이 1이라도 한번은 2배로 늘려야하기 때문에 반복문의 시작값은 0 입니다.
Share article

moohyun