문제 링크입니다: https://www.acmicpc.net/problem/16673
16673번: 고려대학교에는 공식 와인이 있다
첫 번째 줄에 수빈이가 와인을 모은 년수, 수빈이의 고려대 애착 정도, 수빈이의 구매중독 정도를 의미하는 정수 C, K, P가 공백으로 구분되어 주어진다. (0 ≤ C ≤ 100, 0 ≤ K ≤ 1000, 0 ≤ P ≤ 100)
www.acmicpc.net
간단한 수학 공식을 적용하여 푸는 문제였습니다.
1~n까지의 합, 1~n^2까지의 합을 구하는 공식만 안다면 쉽게 풀 수 있으셨을겁니다.
This file contains hidden or 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> | |
using namespace std; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
int C, K, P; | |
cin >> C >> K >> P; | |
long long result = (C * (C + 1) / 2) * K + (C * (C + 1) * (2 * C + 1) / 6) * P; | |
cout << result << "\n"; | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 11375번 열혈강호 (0) | 2020.02.23 |
---|---|
백준 9322번 철벽 보안 알고리즘 (0) | 2020.02.19 |
백준 14395번 4연산 (0) | 2020.02.17 |
백준 2941번 크로아티아 알파벳 (0) | 2020.02.16 |
백준 15970번 화살표 그리기 (0) | 2020.02.14 |