跳到主要內容

發表文章

目前顯示的是 7月, 2013的文章

uva 11550

確認簡單圖 //====================================================================|| // || // || // Author : GCA || // 6AE7EE02212D47DAD26C32C0FE829006 || //====================================================================|| #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <climits> #include <vector> #include <set> #include <map> #include <queue> #include <cctype> #include <utility> using namespace std; #ifdef ONLINE_JUDGE #define ll "%lld" #else #define ll "%I64d" #endif typedef unsigned int uint ; typedef long long int Int; #define Set(a,s) memset(a,s, sizeof (a)) #define Write(w) freopen(w, "w" ,stdout)

uva 11204

簡單的水題 //====================================================================|| // || // || // Author : GCA || // 6AE7EE02212D47DAD26C32C0FE829006 || //====================================================================|| #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <climits> #include <vector> #include <set> #include <map> #include <queue> #include <cctype> #include <utility> using namespace std; #ifdef ONLINE_JUDGE #define ll "%lld" #else #define ll "%I64d" #endif typedef unsigned int uint ; typedef long long int Int; #define Set(a,s) memset(a,s, sizeof (a)) #define Write(w) freopen(w, "w" ,stdout)

uva 11067

BFS+DP 第一次用VIM寫忘記把freopen除掉 多了一堆錯誤 //====================================================================|| // || // || // Author : GCA || // 6AE7EE02212D47DAD26C32C0FE829006 || //====================================================================|| #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <climits> #include <vector> #include <set> #include <map> #include <queue> #include <cctype> #include <utility> using namespace std; #ifdef ONLINE_JUDGE #define ll "%lld" #else #define ll "%I64d" #endif typedef unsigned int uint ; typedef long long int Int; #define Set(a,s) memset(a,s, sizeof (a)) #define Write(w) fre

uva 10692

公式 a^x=a^(x%phi(c)+phi(c))%c //====================================================================|| // || // || // Author : GCA || // 6AE7EE02212D47DAD26C32C0FE829006 || //====================================================================|| #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <climits> #include <vector> #include <set> #include <map> #include <queue> #include <cctype> #include <utility> using namespace std; #ifdef ONLINE_JUDGE #define ll "%lld" #else #define ll "%I64d" #endif typedef unsigned int uint ; typedef long long int Int; #define Set(a,s) memset(a,s, sizeof (a)) #define Write(w) freopen(w

uva 10665

怪怪題目 重打了N遍,打完思緒會很亂 //====================================================================|| // || // || // Author : GCA || // 6AE7EE02212D47DAD26C32C0FE829006 || //====================================================================|| #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <climits> #include <vector> #include <set> #include <map> #include <queue> #include <cctype> #include <utility> using namespace std; #ifdef ONLINE_JUDGE #define ll "%lld" #else #define ll "%I64d" #endif typedef unsigned int uint ; typedef long long int Int; #define Set(a,s) memset(a,s, sizeof (a)) #define Write(w) freopen(w, "w&

uva 10307

利用MST性質即可 //====================================================================|| // || // || // Author : GCA || // 6AE7EE02212D47DAD26C32C0FE829006 || //====================================================================|| #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <climits> #include <vector> #include <set> #include <map> #include <queue> #include <cctype> #include <utility> using namespace std; #ifdef ONLINE_JUDGE #define ll "%lld" #else #define ll "%I64d" #endif typedef unsigned int uint ; typedef long long int Int; #define Set(a,s) memset(a,s, sizeof (a)) #define Write(w) freopen(w, "w" ,std

uva 11115

大數水過 //====================================================================|| // || // || // Author : GCA || // 6AE7EE02212D47DAD26C32C0FE829006 || //====================================================================|| #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <climits> #include <vector> #include <set> #include <map> #include <queue> #include <cctype> #include <utility> using namespace std; #ifdef ONLINE_JUDGE #define ll "%lld" #else #define ll "%I64d" #endif typedef unsigned int uint ; typedef long long int Int; #define Set(a,s) memset(a,s, sizeof (a)) #define Write(w) freopen(w, "w" ,stdout)

uva 10577

很多數學方法 先求出外心,正N邊形的外接圓的中心剛好是外心 求出之後再用旋轉向量去繞 //====================================================================|| // || // || // Author : GCA || // 6AE7EE02212D47DAD26C32C0FE829006 || //====================================================================|| #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <climits> #include <vector> #include <set> #include <map> #include <queue> #include <cctype> #include <utility> using namespace std; #ifdef ONLINE_JUDGE #define ll "%lld" #else #define ll "%I64d" #endif typedef unsigned int uint ; typedef long long int Int; #define Set(a,s) memset(a,s, sizeof (a)) #define Wri

uva 10149

DP MASK技巧 每個dice使用同一種category進行衍生 因為總共所有dice是有13種,而每個category也是13種 且每種category只能被選擇一次,代表所有dice一定會有category裡面的其中一個位置   00000衍生成 00001 –>第一個dice使用第一種category 00010  - >第二個dice使用第一種category...以此類推 00100 01000 10000 之後會衍生成 00011 –>第一個dice使用第一種category,第二個dice使用第二種category ..... 00011 - >第二個dice使用第一種category,第一個dice使用第二種category //====================================================================|| // || // || // Author : GCA || // 6AE7EE02212D47DAD26C32C0FE829006 || //====================================================================|| #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <climits> #include <vector> #include <set> #include <map>

C - Students' Revenge

測試數據非常強...WA了快七八次 了解題目之後,假設測資是 10 7 4 5 5 4 5 4 5 4 5 3 5 3 5 4 4 5 3 4 3 4 3 5 3 2 4 11 5 8 5 6 4 3 9 3 那麼先用b的部分進行遞減排序(上面那串其實就是排完的) 我們可以知道,這個主席他會從學生選的通過方案第一選擇得罪值高的 在選擇頭髮最少變灰色的 所以在排序完之後,學生們知道這些得罪值高的他會優先去做,所以他們還會在去排序頭髮一次 但是如果單純只考慮排序頭髮變灰的話,如上面右邊的測資,他們會選擇9 3這組 之後他們就無法選擇比9 3這組更小的得罪值了,所以我們至少要留p-k個在後面當作無效通過的措施,也就是墊檔用 所以我們會對[0,n-p+k)排序,之後我們把前k個都記錄起來,代表我們需要他來讓主席長頭髮,然後我們挑順序1比那些前k個還大的,就是仇恨值比較小的,用來墊檔   這其中有一個問題,之前我們用b做遞減排序時,如果相等的我們就隨意排,但是我們需要最嚴謹的排法 也就是說,如果我們選了 5 5 4 5 4 5 4 5 依照剛剛的講法,我會選擇 3 5來做我的墊檔措施 但是這個墊檔措施我們不想讓主席執行,可是這個墊檔措施反而有比較好的執行優先權 因為3明顯比4還要小,所以我們一開始排序就要排如果一樣 頭髮就要選擇少的,這樣之後才不會選到更好的措施 //====================================================================|| // || // || // Author : GCA || // 6AE7EE02212D47DAD26C32C0FE829006 || //=========================

B - Maximum Absurdity

先全部加起來再用級數定理取出每個區間的值 然後一一的紀錄從0到i之中最大的區間給i 之後枚舉每個區間並且加上i-k記錄的最大區間,AC //====================================================================|| // || // || // Author : GCA || // 6AE7EE02212D47DAD26C32C0FE829006 || //====================================================================|| #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <climits> #include <vector> #include <set> #include <map> #include <queue> #include <cctype> #include <utility> using namespace std; #ifdef ONLINE_JUDGE #define ll "%lld" #else #define ll "%I64d" #endif typedef unsigned int uint ; typedef long long int Int; #define Set(a,s) memset(a,s,