메뉴 건너뛰기

Programing

Project Euler

6

관리자 2019.12.09 16:36 조회 수 : 149

#include <cstdio>

#include <algorithm>

using namespace std;

 

long long int pow(int max_){

    long long int a=0;

    for(int i=1;i<=max_;i++){

        a+=i*i;

    }

    return a;

}

long long int plus_(int max_){

    long long int a=0;

    for(int i=1;i<=max_;i++){

        a+=i;

    }

    return a*a;

}

int main()

{

    const int max_=100;//1~max_까지

    printf("%lld",max(pow(max_),plus_(max_))-min(pow(max_),plus_(max_)));

    return 0;

}

답: 25164150

번호 제목 글쓴이 날짜 조회 수
공지 안내사항 관리자 2019.12.21 144
6 7 관리자 2023.05.24 105
» 6 관리자 2019.12.09 149
4 5 관리자 2023.05.25 100
3 3 관리자 2023.05.24 98
2 2 관리자 2019.12.09 149
1 1 관리자 2019.12.09 146
위로