原创 POJ_3233 Matrix Power Series【矩陣遞推方法】和 【二分+矩陣快速冪方法】

Given a n × n matrix A and a positive integer k, find the sum S = A + A2 + A3+ … + Ak. Input The input contains exactly

原创 HDU-3579 Hello Kiki 線性同餘方程的運用

題目: One day I was shopping in the supermarket. There was a cashier counting coins seriously when a little kid running a

原创 青蛙的約會 POJ-1061 (擴展歐幾里得算法解同餘方程)

兩隻青蛙在網上相識了,它們聊得很開心,於是覺得很有必要見一面。它們很高興地發現它們住在同一條緯度線上,於是它們約定各自朝西跳,直到碰面爲止。可是它們出發之前忘記了一件很重要的事情,既沒有問清楚對方的特徵,也沒有約定見面的具體位置。不過青蛙

原创 POJ_3233 矩陣快速冪基礎應用

Given a n × n matrix A and a positive integer k, find the sum S = A + A2 + A3+ … + Ak. Input The input contains exactly

原创 POJ_3070 矩陣快速冪實現斐波那契數列變化

In the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn − 1 + Fn − 2 for n ≥ 2. For example, the first ten terms

原创 HDU_2276 矩陣快速冪與二進制的結合

There are n lights in a circle numbered from 1 to n. The left of light 1 is light n, and the left of light k (1< k<= n)

原创 How Many Tables HDU - 1213 (並查集)

Today is Ignatius' birthday. He invites a lot of friends. Now it's dinner time. Ignatius wants to know how many tables

原创 HDU_5015 233 Matrix 矩陣快速冪

這是我矩陣快速冪入門的最後一練,從瞭解矩陣快速冪,到現在應用,其實矩陣快速冪可以分爲兩點,一點是矩陣的相乘,另外一點就是快速冪的掌握,所以並不需要把矩陣快速冪的代碼實現想象的很困難。但是這並不是說矩陣快速冪的應用不難,通過這題,可以感受到

原创 Choosing Ice Cream

You are standing in the supermarket in front of the freezers. You have a very tough task ahead of you: you have to choo

原创 sort用法

#include <algorithm> template< class RandomIt > void sort( RandomIt first, RandomIt last ); template< class RandomI

原创 Farm Irrigation HDU1198 (並查集)

Benny has a spacious farm land to irrigate. The farm land is a rectangle, and is divided into a lot of samll squares. W

原创 nefu118-計算N!末尾0的個數

準備知識:1.(算術基本定理)任何大於1的正整數n都可以表示成素數之積,即素數是整數的乘法構成單位。每個大於1的正整數n都可以被唯一地寫成素數的乘積,在乘積中的素因子按照非降序排列。正整數n的分界式                    

原创 優先隊列的用法

優先隊列和堆一樣有兩種形式:最大優先隊列和最小優先隊列。 1.如果直接定義一個優先隊列,系統默認的爲降序優先隊列。 priority_queue<int > pq; 2. 可以通過系統默認的已有的結構greater<T>來定義一個升序的優

原创 sstream知識點

用sstream這個庫的優勢就在於存入類型的數據可以直接進行轉換,並且不用擔心緩衝區的溢出現象,因爲這些對象會根據需要自動分配空間。 1.istringstream的用法 在C++中有三個類ostringstream、istringst

原创 nefu120-梅森素數(Lucas-Lehmer判定法和Miller測試法)

準備知識:梅森素數:它是發現已知最大素數的有效途徑。如果m是一個正整數,且是一個素數,則2^m-1必是素數。反之,如果m是一個正整數、素數,且2^m-1稱作第m個梅森數;如果p是一個素數,並且也是素數,那麼就稱爲梅森素數。而梅森數可能是素