Description 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 ≤ 30), k (k ≤ 109) and m (m < 104). Then…
Number Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 147964 Accepted Submission(s): 35964 Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A…
http://poj.org/problem?id=3735 大致题意: 有n仅仅猫,開始时每仅仅猫有花生0颗,现有一组操作,由以下三个中的k个操作组成: 1. g i 给i仅仅猫一颗花生米 2. e i 让第i仅仅猫吃掉它拥有的全部花生米 3. s i j 将猫i与猫j的拥有的花生米交换 现将上述一组操作循环m次后,问每仅仅猫有多少颗花生? 非常明显,要先构造矩阵.构造一个(n+1)*(n+1)的矩阵a,初始化为单位矩阵. g i : a[i][n+1] += 1; e i : a[i][j]…
Jzzhu has invented a kind of sequences, they meet the following property: You are given x and y, please calculate fn modulo 1000000007 (109 + 7). Input The first line contains two integers x and y (|x|, |y| ≤ 109). The second line contains a single i…
思路: ax+b cx+d 构造矩阵+矩阵快速幂 (需要加各种特判,,,,我好像加少了- ) //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> using namespace std; #define int long long const int mod=1000000007; int n,m,a,b,c,d;char N[1000500],M[1000500]; stru…