정사각형의 개수

han.user();·2023년 4월 10일
0

구름

목록 보기
10/20
post-thumbnail

import java.io.*;

class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long n = Integer.parseInt(br.readLine()); // long사용해야함

        long result = n * (n + 1) * (2 * n + 1) / 6;  // 공식
        System.out.println(result);
    }
}
profile
I'm still hungry.

0개의 댓글