原创 Game HDU - 3389 (Nim)

Bob and Alice are playing a new game. There are n boxes which have been numbered from 1 to n. Each box is either empty

原创 P2900 [USACO08MAR]土地徵用Land Acquisition (斜率優化dp)

戳 題目描述 Farmer John is considering buying more land for the farm and has his eye on N (1 <= N <= 50,000) additional rect

原创 簡單平面幾何模板(持續更新)

1. 向量基本操作 struct Point { double x, y; }; typedef Point Vector; Vector operator + (Vector a, Vector b) { return { a.x

原创 簡單圖論模板

#define ll long long #define MT(a,b) memset(a,b,sizeof(a)); const int INF  =  0x3f3f3f3f; const int ONF  = -0x3f3f3f3

原创 簡單數據結構模板

1,樹狀數組 int C[maxn<<4] , a[maxn] , n; int lowbit(int x){ return x&(-x); } int Sum(int pos){ int ans = 0;

原创 Number Challenge CodeForces - 235E (莫比烏斯反演)

Number Challenge  CodeForces - 235E    Let's denote d(n) as the number of divisors of a positive integer n. You are giv

原创 中國剩餘定理(CRT) && 擴展中國剩餘定理(EX_CRT)

中國剩餘定理(解決模數互質的同餘方程組)   在《孫子算經》中有這樣一個問題:“今有物不知其數,三三數之剩二(除以3餘2),五五數之剩三(除以5餘3),七七數之剩二(除以7餘2),問物幾何?”這個問題稱爲“孫子問題”,該問題的一般解法國際

原创 2019 Multi-University Training Contest 8 :Andy and Maze 1008(color coding + 狀壓dp)

Andy and Maze Time Limit: 15000/15000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(

原创 P3628 [APIO2010]特別行動隊(斜率優化dp)

特別行動隊 題目描述 你有一支由 n 名預備役士兵組成的部隊,士兵從 1 到 n 編號,要將他們拆分 成若干特別行動隊調入戰場。出於默契的考慮,同一支特別行動隊中隊員的編號 應該連續,即爲形如(i, i + 1, ..., i + k)(

原创 2019 Multi-University Training Contest 8 :Acesrc and Hunting 1004(暴搜)

Problem Description Acesrc is a famous hunter at Nanjing University second to none. Recently, he set n×m traps in Yangs

原创 P2365 任務安排 (斜率優化dp)

P2365 任務安排 題目描述 N個任務排成一個序列在一臺機器上等待完成(順序不得改變),這N個任務被分成若干批,每批包含相鄰的若干任務。從時刻0開始,這些任務被分批加工,第i個任務單獨完成所需的時間是Ti。在每批任務開始前,機器需要啓動

原创 First Knight UVA - 12177 (高斯消元)

題意:給出每個點向四方走的概率,保證和爲1,並且向邊界外走的概率爲0,求從(0, 0)走到(n-1, m-1)的期望步數。 題解:dp[i][j] 表示從 (i,j)走到終點的期望步數, 然後列n * m 個方程, 用高斯消元求解。 注意

原创 Broken robot CodeForces - 24D (特殊矩陣O(n)消元)

You received as a gift a very clever robot walking on a rectangular board. Unfortunately, you understood that it is bro

原创 2019 Multi-University Training Contest 6:Snowy Smile (1005)線段樹

Snowy Smile Time Limit: 4000/4000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others) Total Submission(s):

原创 2019 Multi-University Training Contest 6 :Faraway (1006)

題鏈接 Problem Description n soldiers are dispatched to somewhere in Byteland. These soldiers are going to set off now, bu