编程介的小学生
2019-01-26 16:09C语言的函数算法去解决一个矩阵的问题,涉及到大数的计算怎么实现的?
Problem Description
In mathematics, the Fibonacci numbers are a sequence of numbers named after Leonardo of Pisa, known as Fibonacci (a contraction of filius Bonaccio, "son of Bonaccio"). Fibonacci's 1202 book Liber Abaci introduced the sequence to Western European mathematics, although the sequence had been previously described in Indian mathematics.
The first number of the sequence is 0, the second number is 1, and each subsequent number is equal to the sum of the previous two numbers of the sequence itself, yielding the sequence 0, 1, 1, 2, 3, 5, 8, etc. In mathematical terms, it is defined by the following recurrence relation:
That is, after two starting values, each number is the sum of the two preceding numbers. The first Fibonacci numbers (sequence A000045 in OEIS), also denoted as F[n];
F[n] can be calculate exactly by the following two expressions:
A Fibonacci spiral created by drawing arcs connecting the opposite corners of squares in the Fibonacci tiling; this one uses squares of sizes 1, 1, 2, 3, 5, 8, 13, 21, and 34;
So you can see how interesting the Fibonacci number is.
Now AekdyCoin denote a function G(n)
Now your task is quite easy, just help AekdyCoin to calculate the value of G (n) mod C
Input
The input consists of T test cases. The number of test cases (T is given in the first line of the input. Each test case begins with a line containing A, B, N, C (10<=A, B<2^64, 2<=N<2^64, 1<=C<=300)
Output
For each test case, print a line containing the test case number( beginning with 1) followed by a integer which is the value of G(N) mod C
Sample Input
1
17 18446744073709551615 1998 139
Sample Output
Case 1: 120
- 点赞
- 回答
- 收藏
- 复制链接分享
2条回答
为你推荐
- 【c语言/链表】两个有序单链表合成为一个有序单链表,自己写的代码运行出错,求助
- c语言
- 1个回答
- C语言实现大数加法(正整数)
- c语言
- 2个回答
- c语言编程问题:编写两个函数,求一个3*3矩阵对角线元素之和。
- c语言
- 1个回答
- 用C语言写了一个输入一个一维数组的函数,如何在函数中调用该数组?
- c语言
- 2个回答
- 一个有关加密和解密的算法方面的问题,需要用什么办法实现?C语言
- 解密
- c语言
- components
- 1个回答