Logo
(追記) (追記ここまで)

11238번 - Fibo 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB78848744963.778%

문제

Fibonacci sequence is a well-known integer sequence that has many beautiful properties. Fibonacci sequence is something looks like this 0, 1, 1, 2, 3, 5, 8, 13, 21, … To make it formal, the mathematical term of Fibonacci sequence is define by recurrence relation.

\[F_n = F_{n-1} + F_{n-2} \text{where } n = 2, 3, \dots \text{and } F_0 = 0, F_1 = 1\]

If you know the technique to solve recurrence relation it will look like

\[F_n = \frac{1}{\sqrt{5}} \left\{ \left( \frac{1+\sqrt{5}}{2} \right)^n - \left( \frac{1-\sqrt{5}}{2} \right)^n \right\}\]

And these are some of its beautiful properties (there are a lot more!)

\[\sum_{i=1}^{n}{F_i} = F_{n+2}-1 \\ F_n | F_{kn} \text{where } k = 0, 1, 2, \dots\]

Enough for an introduction, let’s get to the main point. This problem is about finding greatest common divisor (GCD) between Fibonacci numbers. Given two Fibonacci number, your task is to find their GCD! Simple right?

입력

The first line contains a single integer T indicate the number of test cases (1 ≤ T ≤ 1 000)

Each of next T lines contains two integer N, M separated by a space (0 < N, M ≤ 1 000 000 000)

출력

For each test case, print a line contains value of gcd(Fn,Fm) modulo by 1000000 007

제한

예제 입력 1

2
7 10
6 12

예제 출력 1

1
8

힌트

출처

ICPC > Regionals > Asia Pacific > Thailand > Thailand First Round Online > Thailand First Round Online 2014 C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /