摘要:
X-Y Problem 对于X-Y Problem的意思如下: 1)有人想解决问题X2)他觉得Y可能是解决X问题的方法3)但是他不知道Y应该怎么做4)于是他去问别人Y应该怎么做? 简而言之,没有去问怎么解决问题X,而是去问解决方案Y应该怎么去实现和操作。于是乎: 1)热心的人们帮助并告诉这个人Y应该 阅读全文
摘要:
想法: 初始化三個數L=0/1, M=1/1, R=1/0,設輸入的分數為a: 如果a<M,那麼要往左邊走, R = M; M = (L分子+M分子)/(L分母+M分母); 如果a>M,往右邊走, L = M; M = (R分子+M分子)/(R分母+M分母); 如果a==M,停止。 這題和二分搜尋很 阅读全文
摘要:
--> 从而避免了输出格式; 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 int main() 9 {10 int t, count = 0;11 ... 阅读全文
摘要:
《美丽心灵》(A Beatiful Mind)——经典台词美丽心灵经典台词 阅读全文
摘要:
为什么要循规蹈矩呢?如下: 1 #include 2 #define max 2000005 3 4 int main() 5 { 6 int n, age[max], i, j, m; 7 while(scanf("%d", &n), n) 8 { 9 ... 阅读全文
摘要:
已有的数据结构装不下数据,或者不能处理现有的数据,那就必须要思考其他的辅助手段,辅助结构; 1 #include 2 #include 3 #include 4 using namespace std; 5 6 vector order; 7 map freq; 8 9 int main(... 阅读全文
摘要:
1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 9 const char kTable[] = "2223334445556667Q77888999Z... 阅读全文
摘要:
题意为,给你一个序列, 每次交换两个相邻的数使序列为递增的序列, 求最小的交换次数。首先我们可以看出。 最少的交换次数肯定得用归并排序来求了。实际上归并排序的交换次数就是这个数组的逆序对个数,为什么呢?我们可以这样考虑:归并排序是将数列a[l,h]分成两半a[l,mid]和a[mid+1,h]分别进... 阅读全文
摘要:
逆序数的几种求法白话经典算法系列之九 从归并排序到数列的逆序数对(微软笔试题) 阅读全文
摘要:
1 #include 2 #include 3 #include 4 using namespace std; 5 6 int main() 7 { 8 deque cir; 9 long P, C, cas = 0;10 11 while(scanf("%ld%l... 阅读全文