快速幂
so_so_y
start to record bugs <- so hard so brave
展开
-
HDU 1575 Tr A 矩阵快速幂
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原创 2017-02-27 18:07:21 · 412 阅读 · 0 评论 -
51nod 求递推序列的第N项(矩阵快速幂、模拟求循环长度)
Description有一个序列是这样定义的:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. 给出A,B和N,求f(n)的值。Input输入3个数:A,B,N。数字之间用空格分割。(-10000 <= A, B <= 10000, 1 <= N <= 10^9)Output输出f(n)的值。Input示例3 -1 5原创 2017-10-14 11:11:56 · 246 阅读 · 0 评论 -
51nod 1836 战忽局的手段(期望+矩阵快速幂)
众所周知,有一个神秘的组织——战忽局,在暗中保护着我们。在局中任职的官员都有着极强的忽悠技巧,不只能用预言,还能用往事忽悠人。如今某外星间谍已经获得了战忽局曾经参与的n次事件的资料,局座发现了这件事,于是决定再次用忽悠来保证战忽局的安全。局座将发表m次演讲,每一天他都会从n事件中等概率地挑选一件混淆众人,由于局座每天很忙,不能把之前将的事件都记录下来,因此他可能会重复选择某一件事。现在局座想知道,m原创 2017-11-03 18:38:52 · 280 阅读 · 0 评论 -
Codeforces Round #447 (Div. 2) B. Ralph And His Magic Field(思维)
DescriptionRalph has a magic field which is divided into n × m blocks. That is to say, there are n rows and m columns on the field. Ralph can put an integer in each block. However, the magic field does原创 2017-11-20 18:29:39 · 340 阅读 · 0 评论 -
codeforces 621 E. Wet Shark and Blocks(dp+矩阵快速幂)
DescriptionThere are b blocks of digits. Each one consisting of the same n digits, which are given to you in the input. Wet Shark must choose exactly one digit from each block and concatenate all of...原创 2018-02-27 17:19:30 · 323 阅读 · 0 评论 -
51nod 1365 Fib(N) mod Fib(K) & 蓝桥杯 斐波那契(数论)
51nod 1365 Fib(N) mod Fib(K) DescriptionFib(N)表示斐波那契数列的第N项(F(0) = 0, F(1) = 1),给出N和K,求Fib(N) mod Fib(K)。由于结果太大,输出Mod 1000000007的结果。Input第1行:一个数T,表示后面用作输入测试的数的数量。(1 <= T <= 50000) 第2...原创 2018-03-08 19:26:12 · 601 阅读 · 0 评论 -
HDU 6030 Happy Necklace(找规律+矩阵快速幂)
Problem DescriptionLittle Q wants to buy a necklace for his girlfriend. Necklaces are single strings composed of multiple red and blue beads. Little Q desperately wants to impress his girlfriend, h...原创 2018-05-01 20:51:14 · 247 阅读 · 0 评论