백준 #28701번 세제곱의 합

jhj·2024년 2월 4일

백준 JAVA

목록 보기
130/583
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int total = 0;
		for(int i = 1; i <= n; i++) {
			total += i;
		}
		System.out.println(total);
		System.out.println(total * total);
		
		total = 0;
		for(int i = 1; i <= n; i++) {
			total += i * i * i;
		}
		System.out.println(total);
		sc.close();
	}
}
profile
개발자를 꿈꾸는

0개의 댓글