原创 effective c++讓接口容易被正確使用,不易被誤用

class Month { public: static Month Jan(){return Month(1);} static Month Feb(){return Month(2);} //.....

原创 uvaoj 10795 - A Different Task

題解: 1.漢諾塔問題,試圖將初始情況和終止情況通過一箇中間狀態聯繫在一起 總結: 1.這幾天一直在想uvaoj 10253,感覺有點小坎還沒有想出來,感覺以後應該明確解題思路後再寫題,這樣效率會高一些,嗯,寫的過程中發現有

原创 uvaoj 1169 Robotruck

題解: 1.注意輸出格式 總結: 1.保持編程風格一致是一個避免出錯的好主意 2.做事保持冷靜,今天碰到一些影響心情的事情,也算是沒有受到太大的影響,感覺這樣很好。冷靜是很多好習慣的基礎!一定要繼續努力,保持冷靜客觀 3

原创 effective c++:寧以pass-by-reference-to-const替代pass-by-value

class People { public: People() { cout << " construct fun " << endl; } People(const People&

原创 有上下界的可行流,最大流,最小流(模板題)

目錄Loj #115 無源匯有上下界可行流Loj #116 有源匯有上下界最大流Loj #117 有源匯有上下界最小流 Loj #115 無源匯有上下界可行流 #include<cstdio> #include<cstring>

原创 effective c++ 在資源管理類中小心copying 行爲

資源取得時機便是初始化時機 class Mutex{}; void lock(Mutex* p){} void unlock(Mutex* p){} class Lock { public: explicit Lock(M

原创 effective c++在資源管理類中提供對原始資源的訪問

有關訪問資源管理類中的原生指針 #include <iostream> #include <cstdio> using namespace std; struct FontHandle{}; FontHandle getFont(

原创 effective c++以獨立語句將newed對象植入智能指針

int priority(){} struct Widget{}; void processWidget(shared_ptr<Widget>pw,int priority){} int main() { processW

原创 uvaoj 10253 - Series-Parallel Networks

題解: 1.將這道題的模型抽象成一棵樹,計算它有多少種形態 2.例如4條邊,可以拆成1111/112/13/22,3還可拆成111/12,而2只能拆成11,一共可以產生5種形態 3.樹的第一層到第二層的拆解假設算是拆並聯,那

原创 uvaoj 1352 Colored Cubes

大模擬 每日一題 #include<iostream> #include<cstdio> #include<cstring> #include<vector> #include<string> #include<map> usi

原创 effective c++成對使用new 和 delete時要採取相同形式

string *str1 = new string; delete str1;//刪除一個對象 string *str2 = new string[100]; delete []str2;//刪除一個由對象組成的數組 如果使用de

原创 uvaoj 10859 - Placing Lampposts

題解: 1.將放置最少的街燈等價爲最多地方沒有放置街燈個數爲x 2.被兩個街燈照亮的邊數爲b 3.k > b的最大值 4.y = kx + b,找到最大的y 5.樹形dp 總結: 1.將問題歸一化,減少了很多無謂的操

原创 Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2)

Forgetting Things #include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 3e5+20; cons

原创 安裝xv6筆記

os:ubuntu 14.04 首先安裝qemu sudo apt-get install libsdl1.2-dev sudo apt-get install qemu 然後下載xv6 wget https://git

原创 uvaoj 11384 Help is needed for Dexter

題解: 1.發現二分比直接算快一些 2.證明發現二分比三分快一些 #include<iostream> #include<cstring> #include<cstdio> using namespace std; #defi