矩阵快速幂
文章平均质量分 64
CatDsy
一只慵懒的喵
展开
-
Matrix Power Series
题目: Given a n × n matrix A and a positive integer k, find the sum S = A + A^2 + A^3 + … + A^k.题解: 构造矩阵 A A 0 E 与单位矩阵进行k次矩阵乘法代码:#include <stdio.h>#include <stdlib.h>#include <string.h>#include原创 2017-08-18 15:08:40 · 319 阅读 · 0 评论 -
M斐波那契数列
题目描述: M斐波那契数列F[n]是一种整数数列,它的定义如下: F[0] = a F[1] = b F[n] = F[n-1] * F[n-2] ( n > 1 ) 现在给出a, b, n,你能求出F[n]的值吗?( 0 <= a, b, n <= 10^9 ) 由于F[n]可能很大,你只需输出F[n]对1000000007取模后的值即可题解: 列出F[n]的前几项会发现,F原创 2017-08-15 09:27:58 · 497 阅读 · 0 评论 -
Blocks
题目: Panda has received an assignment of painting a line of blocks. Since Panda is such an intelligent boy, he starts to think of a math problem of painting. Suppose there are N blocks in a line and ea原创 2017-08-15 09:42:45 · 310 阅读 · 0 评论 -
Codeforces 621E(dp+矩阵快速幂)
Wet Shark and Blocks题意 有 bbb 组数,每组都有相同的 nnn 个数,现要从每组数中选择一个数,联起来构成一个大数,使其对 xxx 取膜后的值为 kkk ,问有多少种方案?最终答案对 109+7109+710^9 + 7 取膜题解dp[j]dp[j] dp[j] : 对 xxx 取膜后的值为 jjj 的方案数 num[a]num[a]num[a] : 数字...原创 2018-07-24 19:13:31 · 304 阅读 · 0 评论 -
Xor-sequences (codeforces 691E)
ProblemYou are given n integers a1,a2,...,ana1, a2, ..., ana_1, a_2, ..., a_n.A sequence of integers x1,x2,...,xkx1, x2, ..., xkx_1, x_2, ..., x_k is called a “xor-sequence” if for eve...原创 2018-08-23 15:20:54 · 528 阅读 · 0 评论 -
2018 ICPC 徐州网络赛
A. Hard to prepare (dp)题意NNN个客人,主人手上有2k2k2^k个面具。 现在,NNN个人围着圆桌相邻而坐,主人会给他们每个人发一个面具,相邻两个人得到的面具i,ji,ji,j必须满足条件:iii XNORXNORXNOR jjj为正数。 问:有多少种方案?最终答案对 109+7109+710^9 + 7 取膜分析mask[i] XNOR mask[1...原创 2018-09-09 17:34:16 · 1114 阅读 · 0 评论