변의 길이는 x + (x - 1)씩 증가합니다.
n번 만큼 변의길이를 증가시켜주고
n * n을 하여서 전체 점의 개수를 구했습니다.
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
int main(int argc, char *argv[])
{
int n;
int x = 2;
cin >> n;
while(n--) {
x += (x - 1);
}
x *= x;
cout << x << endl;
return 0;
}
'알고리즘' 카테고리의 다른 글
[C++] 백준 4101번 크냐? (0) | 2019.09.18 |
---|---|
[C++] 백준 5337번 웰컴 (0) | 2019.09.18 |
[C++] 백준 14490번 백대열 (0) | 2019.09.17 |
[C++] 백준 2959번 거북이 (0) | 2019.09.17 |
[C++] 백준 5052번 전화번호 목록 (0) | 2019.09.16 |