피너클의 it공부방
백준 14440 정수 수열 (c++) : 피너클 본문
728x90
반응형
https://www.acmicpc.net/problem/14440
14440번: 정수 수열
첫째 줄에 x, y, a0, a1, n이 주어진다. (1 ≤ x, y ≤ 99, 0 ≤ n < 108) a0과 a1은 A0, A1의 마지막 두 자리이다.
www.acmicpc.net
간단한 구현문제다.
숫자를 출력할때 마지막 두자리를 출력해야된다.
1이면 01을 출력해야되고 3이면 03을 출력해야된다.
#include <iostream>
using namespace std;
int x, y, a0, a1, n;
void fib(int n) {
int n1 = a1, n2 = a0;
for (int i = 3; i <= n + 1; i++) {
int n3 = x * n1 + y * n2;
n3 %= 100;
n2 = n1;
n1 = n3;
}
if (n1 >= 10) cout << n1 << endl;
else cout << '0' << n1 << endl;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> x >> y >> a0 >> a1 >> n;
fib(n);
}
전체코드다.
728x90
반응형
'백준' 카테고리의 다른 글
백준 2754 학점계산 (c++) : 피너클 (0) | 2022.07.21 |
---|---|
백준 4101 크냐? (c++) : 피너클 (0) | 2022.07.20 |
백준 2535 아시아 정보올림피아드 (c++) : 피너클 (0) | 2022.07.19 |
백준 2034 반음 (c++) : 피너클 (0) | 2022.07.18 |
백준 1417 국회의원 선거 (c++) : 피너클 (0) | 2022.07.17 |
Comments