#P1306. 斐波那契公约数

    ID: 304 远端评测题 1000ms 125MiB 尝试: 1 已通过: 1 难度: 7 上传者: 标签>数学倍增线性结构递归斐波那契,Fibonacci

斐波那契公约数

Description

For the Fibonacci sequence:

$$f_i = \begin{cases} [i = 1] & i \leq 1 \\ f_{i - 1} + f_{i - 2} & i \gt 1 \end{cases}$$

Compute the greatest common divisor of fnf_n and fmf_m, i.e., gcd(fn,fm)\gcd(f_n, f_m).

Input Format

One line contains two positive integers nn and mm.

Output Format

Output one integer, the greatest common divisor of fnf_n and fmf_m. Print the answer modulo 10810^8.

4 7
1

Hint

  • For 100%100\% of the testdata, it is guaranteed that 1n,m1091 \leq n, m \leq 10^9.

Translated by ChatGPT 5