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

30155번 - Crazy Malvika discovers Crazy Fibonacci function 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB2601076833.831%

문제

Malvika was getting bored of the usual Fibonacci problems, and decided to add a little twist to it. She defined a new function f() with the following properties:

  • She'll give you two integers, A and B. f(1) is defined to be A and f(2) is B.
  • And for all integers x ≥ 2, f(x) = f(x-1) + f(x+1).

She'll give an integer N, and you have to find out what f(N) is. Output the answers modulo 109+7.

입력

The first line of input contains a single integer T denoting number of test cases.

The only line of each test case contains three integers: A, B and N, denoting f(1), f(2) and the query.

출력

For each test case, output a line which contains a single integer, corresponding to f(N) for the given input.

제한

  • 1 ≤ T ≤ 105
  • -109 ≤ A , B ≤ 109
  • 1 ≤ N ≤ 109

예제 입력 1

2
10 17 3
23 17 3

예제 출력 1

7
1000000001

힌트

In the first test case, f(3) = 7, and so that is the output.

In the second test case, f(3) = -6 and the answer modulo 109+7 is 1000000001.

출처

ICPC > Regionals > Asia West Continent > India > The 2015 ACM-ICPC Asia Chennai Regional Contest H번

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

출처

대학교 대회

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

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