原创 01揹包模版

01揹包問題 #include<cstdio> #include<cstring> using namespace std; int maxs(int x,int y) { if(x>y)

原创 完全揹包 動態規劃 模版

問題: XXX上山去採藥。XXX有一個容量爲m(1<=m<=1000)的揹包,他所採集的藥材的總重量不能大於揹包的容量。已知共有n(1<=n<=1000 )種藥材,每種藥材都有無限多,並且知道每種藥材的重量w(1<=w<=m)及價值v(1

原创 2017 HDU 6092 多校聯合賽 Rikka with Subset

As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practic

原创 2017 HDU 6105 多校聯合賽 Gameia

Alice and Bob are playing a game called ‘Gameia ? Gameia !’. The game goes like this : 0. There is a tree with all no

原创 字符串匹配 KMP算法 模版

問題: 給定兩個字符串a、b,求b在a中出現的位置。 輸入: 第一行爲一個字符串a,長度大於等於1小於等於100000。 第二行爲一個字符串b,長度大於等於1小於等於1000。 輸出: 一個整數,b在a中出現的位置,若b不是a的字串,輸

原创 2017 HDU 多校聯合賽 Regular polygon

On a two-dimensional plane, give you n integer points. Your task is to figure out how many different regular polygon t

原创 2017 HDU 多校聯合賽 Colorful Tree

There is a tree with nn nodes, each of which has a type of color represented by an integer, where the color of node i

原创 2017 HDU 6140 多校聯合賽 Hybrid Crystals

Kyber crystals, also called the living crystal or simply the kyber, and known as kaiburr crystals in ancient times, we

原创 2017 HDU 6058 多校聯合賽 Kanade's sum

Give you an array A[1..n] of length n . Let f(l,r,k) be the k-th largest element of A[l..r]. Specially , f(l,

原创 POJ 1125 最短路的水題

#include<cstdio> #define MAX 0x3f3f3f3f using namespace std; int main() { int m; //printf("幾組數據\n"); //scan

原创 最短路徑—Dijkstra算法和Floyd算法

該文章轉自: 博客園 華山大師兄 文章鏈接:http://www.cnblogs.com/biyeymyhjob/archive/2012/07/31/2615833.html 注意:以下代碼 只是描述思路,沒有測試過

原创 百度之星資格賽1003 度度熊與邪惡大魔王

Problem Description 度度熊爲了拯救可愛的公主,於是與邪惡大魔王戰鬥起來。 邪惡大魔王的麾下有n個怪獸,每個怪獸有a[i]的生命值,以及b[i]的防禦力。 度度熊一共擁有m種攻擊方式,第i種攻擊方式,需要消耗k[i]的晶

原创 2017 HDU 多校聯合賽 Balala Power!

alented Mr.Tang has nn strings consisting of only lower case characters. He wants to charge them with Balala Power (he

原创 2017 HDU 6103 多校聯合賽 Kirinriki

We define the distance of two strings A and B with same length n is dis(A,B)= ∑ (i=0→n−1) abs (Ai−Bn−1−i) The differe

原创 最短路問題 (Dijkstra 迪傑斯特拉算法)

可以照圖輸入數據進行驗證 從1到6的最短路爲 9 依然是樸素的代碼 ///最短路(Dijkstra 迪傑斯特拉算法) ***該算法中不能出現負權值*** #include<cstdio> #define MAX