알고리즘

[알고리즘] 백준 28701 - 세제곱의 합 (C++)

blueberrysoda 2024. 11. 14. 23:54

[문제 링크] : https://www.acmicpc.net/problem/28701

#include <iostream>
#include <cmath>
using namespace std;

int main(){
    int N;
    cin >> N;

    int sum = N * (N + 1) / 2;
    int S = sum * sum;
    int Cnt = 0;
    
    for(int i=1; i<=N; i++){
        Cnt += pow(i, 3);
    }
    cout << sum << "\n" << S << "\n" << Cnt << "\n";
    return 0;
}