문제 링크입니다: www.acmicpc.net/problem/2903
2903번: 중앙 이동 알고리즘
상근이는 친구들과 함께 SF영화를 찍으려고 한다. 이 영화는 외계 지형이 필요하다. 실제로 우주선을 타고 외계 행성에 가서 촬영을 할 수 없기 때문에, 컴퓨터 그래픽으로 CG처리를 하려고 한다.
www.acmicpc.net
iteration 0: 4 (2 * 2)
iteration 1: 9 (3 * 3)
iteration 2: 25 (5 * 5)
iteration 3: 81 (9 * 9)
...
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 pow(int p) | |
{ | |
int result = 1; | |
for (int i = 0; i < p; i++) | |
{ | |
result *= 2; | |
} | |
return result; | |
} | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
int N; | |
cin >> N; | |
int side = 2; | |
for (int i = 0; i < N; i++) | |
{ | |
side += pow(i); | |
} | |
int result = side * side; | |
cout << result << "\n"; | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
C++ 백준 2935번 소음 (0) | 2021.04.26 |
---|---|
백준 2921번 도미노 (0) | 2021.04.25 |
백준 2884번 알람 시계 (0) | 2021.04.25 |
백준 2863번 이게 분수? (0) | 2021.04.25 |
백준 2783번 삼각 김밥 (0) | 2021.04.25 |