BOJ_B2_2292
π [B2_2292] λ²μ§
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// Nλ² λ°©
int N = Integer.parseInt(br.readLine());
// 1λ² λ°© λ€λ¦¬κ³ μμ
int cnt = 1;
int j = 1;
if( N==1 ){
cnt = 1;
}
while(N>1){
N -= (6*j);
cnt++;
j++;
}
System.out.println(cnt);
}
}
π€ λμ μκ°
6μ λ°°μλ₯Ό κ³μ μ€μ²©ν΄ λν΄κ°λ κ·μΉμ μ°Ύμλ€.
6, 12, 18, 24 β¦ μ΄λ κ² λ ν΄μ§λ λ§λ€ ν λ²μ© μΉ΄μ΄ν
ν΄μ£Όμλ€.
λ λ€λ₯Έ ν¬μΈνΈλ Nμ΄ 1μΌ λ 1μ λ°ννλλ‘ ν΄μΌνλ€. μ΄κ±Έλ‘ μ μ ν€λ§Έλ€ γ
γ