- 博客(80)
- 收藏
- 关注
转载 POJ 1000~1099
1005 I Think I Need a Houseboat纯吐槽……为什么不是Nice Boat- -|||1022 Packing Unit 4D Cubes先Floodfill填充内部格,然后一个面构成表面的充要条件是它一侧属于方块另一侧不属于方块。1029 False coin根据每次操作,判断每一颗coin是否可能偏重,是否可能偏轻。然后总体判断。...
2019-09-30 08:44:58
166
转载 Chapter 15 Exercises and Problems
Exercises15.5-4 Knuth has shown that there are always roots of optimal subtrees such that root[i,j-1]<=root[i,j]<=root[i+1,j] for all 1<=i<=n. Use this fact to modify the OPTIMAL-BS...
2019-09-30 08:44:55
185
转载 Chapter 14 Exercises
Exercises14.2-2 Can the black-heights of nodes in a red-black tree be maintained as fields in the nodes of the tree without affecting the asymptotic performance of any of the red-black tree ope...
2019-09-30 08:44:53
180
转载 Chapter 11 Exercises and Problems
Exercises11.2-3 Professor Marley hypothesizes that substantial performance gains can be obtained if we modify the chaining scheme so that each list is kept in sorted order. How does the profess...
2019-09-30 08:44:52
319
转载 东方风神录BGM 192kbps mp3 BT下载
利用THxxBGM.exe提取,2~3遍loop的th10 BGM。种子在这里:http://www.cnblogs.com/Files/FancyMouse/東方風神録 ~%20Mountain%20of%20Faith%20BGM%20[th10]%20torrent.rar寒假里一般能保证开种。以上。 转载于:https://www.cnblogs.com/FancyM...
2019-09-30 08:44:50
241
转载 Chapter 13 Exercises
We use the following expression S(T) to show a tree T:if T is null, then S(T) is a null stringif T contains only a root node, S(T) = roototherwise, let L and R are T's left and right subtre...
2019-09-30 08:44:48
188
转载 Chapter 7 Problems
Problems7-3 Stooge sortProfessors Howard, Fine, and Howard have proposed the following "elegant" sorting algorithm: STOOGE-SORT(A,i,j)1 if A[i] > A[j]2 then exchange A[i] <-> A[j...
2019-09-30 08:44:48
157
转载 个人提醒用,ubuntu的设置
提醒自己用1.gvim英文字体错乱/etc/vim/gvimrc去掉一下几行的注释:if has('gui_gtk2') set guifont=Monospace\ 9else set guifont=-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1endif2.compiz...
2019-09-30 08:44:46
156
转载 Chapter 5 Exercises
Exercises5.2-4 Given a permutation A, What is the expected number of indices i such that A[i] = i?The answer is amazingly a constant, 1.Lemma 5.1 The probablity of the permutation that no n...
2019-09-30 08:44:46
136
转载 Chapter 12 Exercises and Problems
Exercises12.1-3 Give a nonrecursive algorithm that performs an inorder tree walk.Here I give a solution that uses no stack but assumes that two pointers can be tested for equality.InorderTr...
2019-09-30 08:44:45
242
转载 Chapter 3 Exercises and Problems
Exercises3.1-4 Is 2^(n+1) = O(2^n)? Is 2^2n = O(2^n)?Yes. No.3.1-7 Prove that o(g(n)) ∩ ω(g(n)) is the empty set.Assuming that there is a function f(n) ∈o(g(n)) ∩ ω(g(n))then f(n) ∈o(...
2019-09-30 08:44:45
299
转载 Chapter 10 Exercises
Exercises10.1-7 Show how to implement a queue using two stacks. Analyze the running time of the queue operations.The amortized time is still O(1) each operation.DATA_TYPE Enqueue(DATA_TYPE ...
2019-09-30 08:44:43
165
转载 NOIP2007提高组题解
数据在这里(from oibh):http://www.cnblogs.com/Files/FancyMouse/NOIP2007.rar1.count一切直接nlogn的算法,在常数不大的时候都能过。我采用的是接近O(n+klogk)的算法,这里k=10000,即不同的数的个数:先把数存放到Hash表中,读完以后再取出Hash表内的数据排序。Hash函数采用mod 9999...
2019-09-30 08:44:43
127
转载 搜集环盖
问题描述“……在2002年6月之前购买的百事任何饮料的瓶盖上都会有一个百事球星的名字。只要凑齐所有百事球星的名字,就可以参加百事世界杯之旅的抽奖活动,获取球星背包、随身听,更可以赴日韩观看世界杯。还不赶快行动!……”你关上电视,心想:假设有n个不同的球星名字,每个名字出现的概率相同,平均需要买几瓶饮料才能凑齐所有的名字呢?输入格式一个数字n,2<=n<=1000,表示不同球星...
2019-09-30 08:44:41
95
转载 Chapter 8 Exercises and Problems
Exercises8.1-3 Show that there is no comparison sort whose running time is linear for at least half of the n! inputs of length n. What about a fraction of 1/n of the inputs of length n? What ab...
2019-09-30 08:44:41
474
转载 TJU1106
不要被(m2-mn-n2)2=1这个条件迷惑而采用搜索。这题m,n,k的范围不允许用搜索的。找找m,n的规律可以发现,其实m,n都是相邻两项Fibonacci数。而且很容易证明得到当F(n-1),F(n)满足那个式子的时候F(n),F(n+1)也一定满足那个式子。#include<iostream>usingnamespacestd;constintN=100...
2019-09-30 08:44:39
131
转载 Chapter 6 Exercises and Problems
Exercises6.4-3 What is the running time of heapsort on an array A of length n that is already sorted in increasing order? What about decreasing order?See 6.4-56.4-5 Show that when all ele...
2019-09-30 08:44:39
354
转载 TJU1279
题目意思很明确,知道四面体六条棱长求体积。数学问题,我们把四面体四个顶点放到坐标系中,并把A点设为原点,B坐标(x1,0,0),C坐标(x2,y2,0),D坐标(x3,y3,z3)。由于6条边,可以列出6个方程,因此可以解出x1,x2,y2,x3,y3,z3。而z3就是ABC面上的高。把ABC面积乘以z3再除以3就是答案了。#include<iostream>#inclu...
2019-09-30 08:44:36
94
转载 Chapter 4, FAQ about Master Theorm, exercises and problems
FAQ about the Master theoremQ1: Why in case 1, f(n) must be polynomially smaller than n^log(b,a)?Recall the lemma proved in the proof of the master theoremi.e. for T(n) = a*T(n/b) + f(n)T...
2019-09-30 08:44:36
220
转载 Chapter 2 Exercises and Problems
Exercises2.2-4 How can we modify almost any algorithm to have a good best-case running time?CHEAT. Is there any OIer who can not cheat? That's O(1).2.3-6 Can we use a binary search instea...
2019-09-30 08:44:34
131
转载 TJU1036
问题的关键是如何将这些满足要求的数排序。我们可以将数组下标为0的元素设为1,并且将3个指针均放在它的位置上。以后,第i个指针乘以第i个数(i=1,2,3),取最小的放入数组,并且更新指针。这样可以保证数组里的元素都是单调递增而且不漏掉一个的。问题就解决了。#include<iostream>usingnamespacestd;constlongk=100000...
2019-09-30 08:44:34
71
转载 关于启用DMA的方法
这是一个老问题……希望对那些不幸遇到的朋友有点帮助当然,这里的前提是:主板、硬盘(光驱)都支持DMA,驱动程序安装正确,启用了DMA模式但是仍然在低速DMA或PIO下运行的情况。问题的产生:在Windows 2000/XP/2003中有这样一个设定: Windows IDE/ATAPI 端口驱动程序 (Atapi.sys) 累积收到总共6个超时或循环冗余检验(CRC)错误后,...
2019-09-30 08:44:32
625
转载 TJU1173
在思考这题的时候想到了一个很好的解法。建立一棵用数组模拟的树,每个结点的值类型是一个char,内容是ABC中的一个。先把原01串处理为AB串并作为叶子结点,然后两个两个合并。合并的时候,两结点全A或全B时,父结点值为A或B,否则为C。树建立起来以后,先序遍历即可。注意只有在一个结点的值为C的时候才访问左右孩子。#include<iostream>#include<c...
2019-09-30 08:44:32
88
转载 TJU1096
基本思路是把每一个字符(1或0)看作一棵2叉树的叶结点,然后一层一层向上合并。合并规则是:如果两个都是"A",那合并为"A";两个都是"B"则合并为"B";否则就是"C"然后追加这两个字符串 在实现的过程中可以用一个队列来代替。初始化的时候把所有字符当作字符串塞进去,然后每次取出两个,处理后塞进去一个。可以证明,由于基因编码长度为2^k,因此每次取出的两个对应的原基因编码长度必定相等(就...
2019-09-30 08:44:30
102
转载 TJU1040
用DP的思想保存已经求出的解的话速度会快一些。保存现今求出的所有取自x1~xm的数mod n的余数。扩展的时候就用一个余数乘以10,分别加上x1~xm,判断是否mod n为0,如果是,输出解,否则存入队列继续查找。#include<iostream>usingnamespacestd;constintmax_size=0x40000;intqueue[max...
2019-09-30 08:44:28
78
转载 TJU1093
两条航线交叉的充要条件是x1>x2,y1<y2。以x为关键字排序以后,满足条件的序列一定是单调的……发现了什么?原来此题就是排序+最大单调子序列问题。#include<iostream>usingnamespacestd;constintMaxN=2004;typedefstructharbor{intA,B;}harbor;voidSor...
2019-09-30 08:44:28
62
转载 TJU1076
要注意该函数mod7的余数一定是循环的。设法求出循环节长度,并且保留一个完整的循环节,程序接下来就没问题了~#include<iostream>usingnamespacestd;constintN=7;intloop;intf[55];voidsFibonacci(inta,intb);intsFibonacci(longn);intmain...
2019-09-30 08:44:27
83
转载 TJU1105
先用不定积分求出那个v=t2的,s=t3/3。然后列一个方程求根了。三次方程有求根公式,但是偶还米学到,所以就用二分叠代来求这个根了~#include<iostream>#include<iomanip>usingnamespacestd;doublef(doublea,doublek,doublex);intmain(){double...
2019-09-30 08:44:27
79
转载 TJU1095
这题略带一些技巧。注意有5因子的数的处理。可以发现乘一个5与乘一个8的效果相同。于是我们对于每一个含有5因子的数在乘的时候做一下处理即可~#include<iostream>usingnamespacestd;constintN=101;constinta[10]={1,1,2,6,4,4,4,8,4,6};intPositive(intn[N])...
2019-09-30 08:44:25
66
转载 TJU1050
典型的DP,开一个数组,第i个元素记录原字符串中以第i个字符结束的最小划分数。d[i] = min{d[j] + 1},0<=j<i,并且j~i之间的字符串可以在字典中查到。#include<iostream>#include<cstring>usingnamespacestd;constintMaxString=256;classD...
2019-09-30 08:44:25
80
转载 TJU1091
只要两个数加法不产生进位就能满足题意。对于首位来说,可以有8*9/2=36种选数方式(因为首位不为0),对于其他位来说,可以有9*10/2=55种选数方式,乘法原理以后,剩下来的就是大数乘法和输出了。#include<iostream>usingnamespacestd;constintMAX=100;classNum{public:Num(int...
2019-09-30 08:44:23
59
转载 TJU1025
DFS(深搜),注意优化一下剪枝和求最小未使用数这两部分的代码就行了。#include<iostream>usingnamespacestd;intPrimeList[50];intboard[100];intNumUsed[101],MinNum;intsize;voidSolve();intAcceptable(intk,intcur);int...
2019-09-30 08:44:23
105
转载 TJU1059
这题……noip普及组原题的数据规模1000,太简单了。这里被弄到了3000000……从oi到oj的提升哈~先要解决算法的问题。很容易得出f(x)的递推式f(0)+f(1)+f(2)+...+f(x/2)。但是,如果就照这个算的话,tle~~O(n^2)的复杂度,对于3000000的数据,能在1秒出解就……于是要换个思路。我们计s(x)=f(0)+f(1)+...+f(x)。这样,f(x...
2019-09-30 08:44:21
81
转载 TJU1034
寻找四塔函数g(x)的递推式。我们将普通的3塔,即Hanoi塔问题的函数式记作f(x),易得f(x)=2^x-1。我们设一开始把x块东西中的a块放到第二个柱子上,这步用了g(a)次,然后,接下来x-a块放到第四个柱子上,由于只有3个柱子可以用,因此这步用了f(x-a)次。然后再把a块移过去用了g(a),所以总共消耗2*g(a)+f(x-a),所以g(x) = min{2*g(a)+f(x...
2019-09-30 08:44:18
92
转载 TJU1030
考组合数学的一道题就拿keneta作为例子(注意这个字符串和Sample Input那个不一样),我们要做的是判断keneta前面有几个字符串。由于在k的字母顺序之前的有a和e,因此我们考虑第一位是a的时候,此时是1个k,2个e,1个n,1个t的排列;然后是第一位是e的时候,1k1e1n1t1a。然后,第一位是k的时候,再考虑第二位的情形。依此类推可以将keneta前的字符串个数求出来。...
2019-09-30 08:44:16
78
转载 TJU1081
没错,看懂题目即可#include<iostream>#include<cmath>usingnamespacestd;#defineYES{cout<<"It'saMaoLaoDanumber."<<endl;continue;}#defineNO{cout<<"It'snotaMaoLaoDan...
2019-09-30 08:44:15
70
转载 TJU1049
对于任何一个重量都存储一个状态变量,将0重量初始化为1,然后遍历所有砝码,碰到i是1,就将i+wj*k,k=1~nj都设置为1。最后遍历状态变量统计1的数量#include<iostream>usingnamespacestd;intmain(){intstatus[20001],i,j,data,quantity,weight[20],number[20...
2019-09-30 08:44:14
74
转载 TJU1039
设f(n,m)为所求答案,则f(n,m)求得是:2^n,当m>n;2f(n-1,m) - f(n-m-1,m),当m<=n首先,m>n的时候是2^n很好理解,所有2^n种放法均满足要求然后就是m<=n的情况了。我们用递推的思维思考。对于f(n-1,m)种情况,在它们后面无论加1、加0都是可以作为一个等待确认的解的。这里就是2f(n-1,m)。但是,在后面加1的时候...
2019-09-30 08:44:14
67
转载 TJU1046
其实很简单。假设(1,1,1)染成黑色,然后对于所有小立方体黑白相间染色。则边长为偶数的时候,可以吃完馅饼的充要条件是两个格子同色;边长为奇数的时候,充要条件是两个格子都是黑色。待本人严格证明~~#include<iostream>usingnamespacestd;intmain(){intsize,x1,x2,x3,y1,y2,y3,data;...
2019-09-30 08:44:12
74
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅