![[백준 / BOJ] 15596번 정수 N개의 합 (C++, Python)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fbjh3j6%2FbtrJhjb45Q4%2FQ6sY1JIAEls90GXJ3fNsx0%2Fimg.png)
[백준 / BOJ] 15596번 정수 N개의 합 (C++, Python)◎ 자료구조와 알고리즘/백준(BOJ) 문제풀이2021. 9. 5. 15:58
Table of Contents
반응형
링크 : https://www.acmicpc.net/problem/15596
15596번: 정수 N개의 합
C++17, Java 8, Python 3, C11, PyPy3, C99, C++98, C++11, C++14, Go, C99 (Clang), C++98 (Clang), C++11 (Clang), C++14 (Clang), C11 (Clang), C++17 (Clang)
www.acmicpc.net
문제

문제 풀이
문제 조건에 작성해야 하는 함수의 틀이 나와있으므로 그대로 따라주면 된다.
C++ 코드 전문
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
long long sum(std::vector<int> &a) | |
{ | |
long long ans = 0; | |
for (int i = 0; i < a.size(); i++) | |
{ | |
ans = ans + a[i]; | |
} | |
return ans; | |
} |
Python 코드 전문
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solve(a): | |
return sum(a) |
소감
반응형
'◎ 자료구조와 알고리즘 > 백준(BOJ) 문제풀이' 카테고리의 다른 글
[백준 / BOJ] 1065번 한수 (C++, Python) (0) | 2021.09.07 |
---|---|
[백준 / BOJ] 4673번 셀프 넘버 (C++, Python) (0) | 2021.09.06 |
[백준 / BOJ] 4344번 평균은 넘겠지 (C++, Python) (0) | 2021.09.05 |
[백준 / BOJ] 8958번 OX퀴즈 (C++, Python) (0) | 2021.09.05 |
[백준 / BOJ] 1546번 평균 (C++, Python) (0) | 2021.09.05 |
@Reo :: 코드 아카이브
자기계발 블로그