原创 CCF認證 201812-1 小明上學

#include <iostream> using namespace std; int main(){ int r,y,g; scanf("%d%d%d",&r,&y,&g); int n,cnt=0,k,x;

原创 CCF認證 201909-1 小明種蘋果

#include <iostream> using namespace std; int main() { int n,m; int T=0,k=1,p=0; scanf("%d%d",&n,&m); f

原创 樹形dp(以點爲單位)

這一題與《戰略遊戲》那道題還是有些不同的 上一題狀態設計爲每個節點選或不選,在轉移的時候每條邊至少選一個就可以維護出當前子樹中正確的選法中最小的 本題就需要更爲複雜的轉移了,因爲你不能通過當前父節點選或不選來判斷出子節點選或不選,本題要求

原创 構造最大生成樹

P1967 貨車運輸 AC代碼: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #inclu

原创 CCF認證 201812-3 CIDR合併

#include <iostream> #include <algorithm> #include <cstring> #include <vector> using namespace std; const int N = 10000

原创 CCF認證 201909-3 字符畫

把單個字符轉化爲字符串  string(1, char(27)) #include <iostream> #include <cstring> using namespace std; const int N = 2000; stru

原创 CCF認證 201903-3 損壞的RAID5

#include <iostream> #include <cstring> #include <iomanip> using namespace std; const int N = 1e7; struct { int id, pos

原创 C 數據格式

0x數據  => 16進制,0數據  => 8進制,直接數據  => 10進制 %d %o %x %X 分別是 10進制,8進制,16進制(小寫), 16進制(大些)的輸出格式

原创 7-7 階乘的非零尾數 (20分)

      #include <iostream> #include <cmath> #include <cstring> using namespace std; int main(){ int n, k; cin

原创 快速求解素因子

這個方法和篩法思想很像啊,但是比篩法更節省空間 #include <iostream> #include <cstdio> using namespace std; int main(){ long long n; scanf("%

原创 P2827 蚯蚓

P2827 蚯蚓   本題主要有4個任務:找最值,刪,插入px、x-px,長q 本題要注意隱含的單調性,先被切掉的蚯蚓分成的蚯蚓一定比後切掉的蚯蚓分成的蚯蚓大;還要注意偏移量的使用,除了被切的那條蚯蚓,其餘所有蚯蚓的長度每秒內均增長q,所

原创 對頂堆

洛谷 1168 中位數 題目描述 給出一個長度爲NN的非負整數序列A_iAi​,對於所有1≤k≤(N+1)/2,輸出A1​,A3​,…,A2k−1​的中位數。即前1,3,5,…個數的中位數。 輸入格式 第1行爲一個正整數N,表示了序列長度

原创 136. 鄰值查找

136. 鄰值查找 給定一個長度爲 n 的序列 A,A 中的數各不相同。對於 A 中的每一個數 Ai,求: min1≤j<i |Ai−Aj| 以及令上式取到最小值的 j(記爲 Pi)。若最小值點不唯一,則選擇使 Aj 較小的那個。 輸入格

原创 CCF認證 201903-4 消息傳遞接口

#include <iostream> #include <queue> #include <list> #include <unordered_set> #include <cstring> using namespace std;

原创 樹形dp(以邊爲單位)

下面是兩道例題: 設當前父節點爲x,其子節點爲y1,y2,...,yn 《沒有上司的舞y2會》:每條邊上最多選擇一個點,求最大權值 狀態轉移方程: f[x,0]=max(f[y1,0],f[y1,1])+max(f[y2,0],f[y2,