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 | 29 | 30 |
Tags
- Sort
- 오블완
- map
- 다이나믹프로그래밍
- Set
- int
- 문자열
- stoi
- BFS
- 백트래킹
- priority_queue
- 배열
- C++
- DFS
- 알고리즘
- 분할정복
- vector
- N과M
- 티스토리챌린지
- DP
- 백준
- 에라토스테네스의 체
- 정렬
- 그래프
- 깊이우선탐색
- 최소공배수
- 유클리드호제법
- 우선순위큐
- 프로그래머스
- 이분탐색
Archives
- Today
- Total
안녕 세상아,
[c++/백준] 1003 피보나치 함수 본문
https://www.acmicpc.net/problem/1003
1003번: 피보나치 함수
각 테스트 케이스마다 0이 출력되는 횟수와 1이 출력되는 횟수를 공백으로 구분해서 출력한다.
www.acmicpc.net
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
int zero[45] = {};
int one[45] = {};
zero[0] = 1;
zero[1] = 0;
one[0] = 0;
one[1] = 1;
for (int i = 2; i < 45; i++) {
zero[i] = zero[i - 1] + zero[i - 2];
one[i] = one[i - 1] + one[i - 2];
}
for (int i = 0; i < t; i++) {
int x;
cin >> x;
cout << zero[x] << " " << one[x] << endl;
}
}
'백준' 카테고리의 다른 글
[c++/백준] 2606 바이러스 (1) | 2023.05.08 |
---|---|
[c++/백준] 1966 프린터 큐 (1) | 2023.05.08 |
[c++/백준] 9095 1, 2, 3 더하기 (0) | 2023.05.05 |
[c++/백준] 1929 소수 구하기 (0) | 2023.05.05 |
[c++/백준] 1463 1로 만들기 (0) | 2023.05.04 |