코드포스 492A (codeforces 492A)

코드포스 492A (codeforces 492A) 문제 풀이 및 코드 (description and code)

Problem - 492A - Codeforces

코드

import java.io.*;

public class CF492A {
    static int n, ans = 0, j = 1, count = -1;
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        n = Integer.parseInt(br.readLine());
        for (int i = 2; ans <= n ; i++) {
            ans += j;j += i;
            count++;
        }
        bw.write(count + "\n");
        bw.flush();bw.close();
    }
}

설명

Copied to clipboard