Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 그리디 알고리즘
- 백트래킹
- 정렬
- DFS
- ue5
- Team Fortress 2
- 유니온 파인드
- 투 포인터
- 다이나믹 프로그래밍
- Unreal Engine 5
- 수학
- 다익스트라
- 트리
- 누적 합
- 재귀
- XR Interaction Toolkit
- 브루트포스
- VR
- 우선순위 큐
- c++
- 구현
- 유니티
- 알고리즘
- 시뮬레이션
- 스택
- 문자열
- 자료구조
- 그래프
- 백준
- BFS
Archives
- Today
- Total
1일1알
백준 2748번 피보나치 수 2 C++ 본문
dp[ i ] = dp[ i - 2 ] + dp[ i - 1 ] , int 범위를 넘어가기 때문에 long long으로 선언하였다.
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
vector<ll> dp(91, 0);
dp[1] = 1;
int n;
cin >> n;
for (int i = 2; i <= n; i++) {
dp[i] = dp[i - 2] + dp[i - 1];
}
cout << dp[n];
};
'알고리즘' 카테고리의 다른 글
백준 2206번 벽 부수고 이동하기 C++ (0) | 2022.02.28 |
---|---|
백준 1987번 알파벳 C++ (0) | 2022.02.27 |
백준 4577번 소코반 C++ (0) | 2022.02.25 |
백준 11066번 파일 합치기 C++ (0) | 2022.02.23 |
백준 23029번 시식 코너는 나의 것 C++ (0) | 2022.02.22 |