原创 So Easy! HDU - 4565 矩陣快速冪

題目鏈接:點我  A sequence S n is defined as:   Where a, b, n, m are positive integers.┌x┐is the ceil of x. For example,

原创 M斐波那契數列 HDU - 4549 矩陣快速冪

題目鏈接 M斐波那契數列F[n]是一種整數數列,它的定義如下: F[0] = a F[1] = b F[n] = F[n-1] * F[n-2] ( n > 1 ) 現在給出a, b, n,你能求出F[n]的值嗎? I

原创 Power of Matrix UVA - 11149(矩陣倍增)

題目鏈接:點我 題意: 給你一個矩陣 A, 讓你求 A + A2 + A3 + A4 + A5 + …. An , 思路: 矩陣倍增,那麼怎麼倍增呢, 令矩陣 S = A + A2 + A3 + A4 + A5

原创 Bear in the Field CodeForces - 385E 矩陣快速冪

題目鏈接:點我 Our bear's forest has a checkered field. The checkered field is an n × n table, the rows are numbered from

原创 Yet Another Number Sequence CodeForces - 392C 矩陣快速冪

題目鏈接:點我 Everyone knows what the Fibonacci sequence is. This sequence can be defined by the recurrence relation: F1

原创 ZOJ 3687 The Review Plan I 禁位排列 | 容斥原理

題目鏈接 Michael takes the Discrete Mathematics course in this semester. Now it's close to the final exam, and he wan

原创 Cellular Automaton UVA - 1386 矩陣快速冪 & 循環矩陣

題目鏈接:點我 題意: 一個細胞自動機,有n個格子,每個格子的取值爲0~m-1。給定距離d,每次操作後每個格子的值將變爲到它距離不超過d的所有格子在操作之前的值之和除以m的餘數。 思路: 循環矩陣,矩陣快速冪; 我們可以發現,

原创 Count Squares HDU 3432

題目鏈接: Given a set of points with integer coordinates xi, yi, i = 1...N, your program must find all the squares hav

原创 NUMBER BASE CONVERSION POJ 1220 進制轉換模板

題目鏈接 Write a program to convert numbers in one base to numbers in a second base. There are 62 different digits: {

原创 ACM計算幾何題目推薦

一。點,線,面,形基本關係,點積叉積的理解 POJ 2318 TOYS(推薦) http://acm.pku.edu.cn/JudgeOnline/problem?id=2318 POJ 2398 Toy Storage(推薦

原创 Connected Graph POJ1737 高精度

題目鏈接 An undirected graph is a set V of vertices and a set of E∈{V*V} edges.An undirected graph is connected if and

原创 ZOJ 3574 Under Attack II 歸併排序求逆序對

題目鏈接 Because of the sucessfully calculation in Under Attack I, Doctor is awarded with Courage Cross and promoted

原创 Construct a Matrix FZU - 1911 矩陣快速冪

題目鏈接:點我 There is a set of matrixes that are constructed subject to the following constraints: 1. The matrix is a

原创 Recurrences UVA - 10870 矩陣快速冪

題目鏈接:點我 題意: 如題給出的公式,讓你求 f(n) mod m的值; 思路: 矩陣快速冪; 根據題意構造矩陣爲: ⎛⎝⎜⎜⎜⎜⎜⎜a110.....a201.......a300.......a400....0....

原创 Number of Battlefields UVA - 11885 矩陣快速冪

題目鏈接:點我 題意: 給周長,求能圍成的戰場數目,不包括矩形。 思路: 矩陣快速冪; 如果包含矩形的話,對應的則是斐波那契數列的偶數項,所以對應減去矩形的個數即可 代碼: #include<cstdio> #include<