最长上升子序列.虽然数据可以直接n方但是另写了个nlogn的 转移:f[i]=max(f[j]+1)(a[j]<a[i]) O(n^2) #include<iostream> #include<cstdio> using namespace std; const int N=5005; int n,a[N],f[N],ans; int read() { int r=0,f=1; char p=getchar(); while(p>'9'||p<'0') { if(…
Dr. Ellie Arroway has established contact with an extraterrestrial civilization. However, all efforts to decode their messages have failed so far because, as luck would have it, they have stumbled upon a race of stuttering aliens! Her team has found…
text = 'The rain in Spain falls mainly in the plain.'first = Hash.new []second = Hash.new {|hash,key| hash[key] = []} text.split(/\W+/).each do |word| p "word: #{word}" p first[word[0, 1].downcase].object_id first[word[0, 1].downcase] << w…
1. sort → new_ary click to toggle source sort { |a, b| block } → new_ary Returns a new array created by sorting self. Comparisons for the sort will be done using the <=> operator or using an optional code block. The block must implement a comparison…
1.list转数组 例如: List<String> list = new ArrayList<String>(); list.add("aa"); list.add("bb"); String[] st = (String[])list.toArray(); //错误. 此处编译时会报错(java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [L…