矩阵快速幂
NineFailure
这个作者很懒,什么都没留下…
展开
-
HDU1575 矩阵快速幂入门
Problem Description A为一个方阵,则Tr A表示A的迹(就是主对角线上各项的和),现要求Tr(A^k)%9973。Input 数据的第一行是一个T,表示有T组数据。 每组数据的第一行有n(2 <= n <= 10)和k(2 <= k < 10^9)两个数据。接下来有n行,每行有n个数据,每个数据的范围是[0,9],表示方阵A的内容。Output 对应每组数据,输出Tr(A原创 2016-10-12 14:45:49 · 317 阅读 · 0 评论 -
Codeforces Round #307 (Div. 2)D
D. GukiZ and Binary Operations time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output We all know that GukiZ often plays with arrays.Now he is thi原创 2017-03-01 11:51:17 · 349 阅读 · 0 评论 -
HDU4549 费马小定理应用
M斐波那契数列Fnn是一种整数数列,它的定义如下: F00 = a F11 = b Fnn = Fn−1n−1 * Fn−2n−2 ( n > 1 ) 现在给出a, b, n,你能求出Fnn的值吗? Input 输入包含多组测试数据; 每组数据占一行,包含3个整数a, b, n( 0 <= a, b, n <= 10^9 ) Output 对每组测试数据请输出一个整数Fnn,由于原创 2017-05-30 01:29:15 · 521 阅读 · 0 评论 -
HDU4686
An Arc of Dream is a curve defined by following function: where a 0 = A0 a i = a i-1*AX+AY b 0 = B0 b i = b i-1*BX+BY What is the value of AoD(N) modulo 1,000,000,007? Input There are multi原创 2017-05-30 16:19:51 · 378 阅读 · 0 评论 -
HDU4565
A sequence S n is defined as: Where a, b, n, m are positive integers.┌x┐is the ceil of x. For example, ┌3.14┐=4. You are to calculate S n. You, a top coder, say: So easy! Input There are several原创 2017-05-31 17:41:49 · 520 阅读 · 0 评论 -
HDU3306
As we all known , the Fibonacci series : F(0) = 1, F(1) = 1, F(N) = F(N - 1) + F(N - 2) (N >= 2).Now we define another kind of Fibonacci : A(0) = 1 , A(1) = 1 , A(N) = X * A(N - 1) + Y * A(N - 2) (N >=原创 2017-06-06 00:55:29 · 339 阅读 · 0 评论 -
HDU5950(67/600)
Farmer John likes to play mathematics games with his N cows. Recently, they are attracted by recursive sequences. In each turn, the cows would stand in a line, while John writes two positive numbers a原创 2017-07-28 20:09:06 · 388 阅读 · 0 评论 -
poj3233(81/600)
Given a n × n matrix A and a positive integer k, find the sum S = A + A2 + A3 + … + Ak.Input The input contains exactly one test case. The first line of input contains three positive integers n (n ≤ 3原创 2017-08-07 12:20:39 · 311 阅读 · 0 评论