문제 링크입니다: www.acmicpc.net/problem/2921
2921번: 도미노
도미노는 여러 종류의 타일 게임에서 사용하는 조각이다. 도미노 조각은 두 칸으로 이루어져 있다. 각 칸에는 점이 찍혀있는데, 점이 안 찍혀져 있을 수도 있다. 점의 개수는 세트의 크기에 의
www.acmicpc.net
간단한 구현 문제였습니다.
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 N; | |
cin >> N; | |
int upper = 0; | |
for (int i = 1; i <= N; i++) | |
{ | |
upper += i * (i + 1) / 2; | |
} | |
int lower = 0; | |
for (int i = 1; i <= N; i++) | |
{ | |
lower += i * (i + 1); | |
} | |
int result = lower + upper; | |
cout << result << "\n"; | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 19771번 Сапсан (0) | 2021.04.27 |
---|---|
C++ 백준 2935번 소음 (0) | 2021.04.26 |
백준 2903번 중앙 이동 알고리즘 (0) | 2021.04.25 |
백준 2884번 알람 시계 (0) | 2021.04.25 |
백준 2863번 이게 분수? (0) | 2021.04.25 |