原创 POJ 1015 DP

動態規劃。       爲敘述問題方便,現將任一選擇方案中,辯方總分和控方總分之差簡稱爲“辯控差”,辯方總分和控方總分之和稱爲“辯控和”。第i 個候選人的辯方總分和控方總分之差記爲V(i),辯方總分和控方總分之和記爲S(i)。 現用

原创 HDU 2819 二分匹配

// // main.cpp // HDU 2819 二分匹配 // // Created by 鄭喆君 on 8/12/14. // Copyright (c) 2014 itcast. All rights reserved.

原创 HDU 2824 歐拉函數 求小於等於n且與n互質數的個數

#include"stdio.h" #include"string.h" #include"stdlib.h" #define N 3000011 int phi[N]; void getphi() { int i,j; phi[1]

原创 歐拉回路和歐拉路徑求法 dfs遞歸模板

#include<cstdio> #include<cstring> #include<iostream> #include<iomanip> #include<queue> #include<cmath> #include<stack>

原创 BestCoder #1-1 HDU 4857 逆拓撲排序

// // main.cpp // HDU 4857 拓撲排序 // // Created by 鄭喆君 on 8/9/14. // Copyright (c) 2014 itcast. All rights reserved.

原创 HDU 3664 DP

// // main.cpp // HDU 3664 DP // // Created by 鄭喆君 on 8/11/14. // Copyright (c) 2014 itcast. All rights reserved. /

原创 歐拉函數 素數篩選法模板

long long p[maxn],e[maxn]; bool hash[maxn]; void init() { memset(hash,0,sizeof(hash)); memset(hash,0,sizeof(e));

原创 POJ 2479 DP

// // main.cpp // POJ 2479 DP // // Created by 鄭喆君 on 8/11/14. // Copyright (c) 2014 itcast. All rights reserved. /

原创 POJ 3159 差分約束+迪傑斯特拉+優先隊列 圖的數據結構用數組表示

#include<cstdio> #include<cstring> #include<iostream> #include<iomanip> #include<queue> #include<cmath> #include<stack>

原创 POJ 1661 DP 注意邊界條件。。。WA了好幾次

// // main.cpp // POJ 1661 DP // // Created by 鄭喆君 on 8/12/14. // Copyright (c) 2014 itcast. All rights reserved. /

原创 HDU 2822 BFS+優先隊列

// // main.cpp // HDU 2822 BFS+優先隊列 // // Created by 鄭喆君 on 8/13/14. // Copyright (c) 2014 itcast. All rights reser

原创 HDU 3666 差分約束+判斷有沒有負環

// // main.cpp // HDU 3666 差分約束 // // Created by 鄭喆君 on 8/8/14. // Copyright (c) 2014 itcast. All rights reserved.

原创 POJ 1364 差分約束

一直不知道差分約束是什麼類型題目,最近在寫最短路問題就順帶看了下,原來就是給出一些形如x-y<=b不等式的約束,問你是否滿足有解的問題 好神奇的是這類問題竟然可以轉換成圖論裏的最短路徑問題,下面開始詳細介紹下 比如給出三個不等式,b

原创 BestCoder #1-2 HDU 4858

暴力的方法能過,但是網上有更優化的方法, #include <iostream> #include <string.h> #include <stdio.h> #include <algorithm> #include <vector>

原创 HDU 3018 歐拉回路 筆畫數問題

Ant Trip Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 156