2012年5月29日

摘要: 坑点:0特判View Code const double esp=1e-11;string ElectionFraudDiv2::IsFraudulent(vector <int> percentages) { vector <double> sb ; double sum=0; for (int i = 0 ; i < percentages.size() ; i++) { sum+=percentages[i]+0.0; sb.push_back(percentages[i]+0.0); } double sum1,sum2;... 阅读全文
posted @ 2012-05-29 23:56 LegendaryAC 阅读(176) 评论(0) 推荐(0) 编辑
 
摘要: O(nlog(n))的算法,网上讲解有很多,我就不在这里献丑了,直接上模板该模板计算从1到n的LIS,p[]为存放数列的数组最长上升子序列View Code int LIS(int n){ int l,r,m,i,tail = 0; for ( dp[ ++ tail ] = p[ 1 ... 阅读全文
posted @ 2012-05-29 12:28 LegendaryAC 阅读(357) 评论(0) 推荐(0) 编辑
 
摘要: 今天起决定总结自己做题写出来的遇到的找到的各种模板,先从输入挂开始啦有的题目需要大规模输入,很多情况用cin超时,用scanf就能过,因为scanf的速度远远快于cin。但是比scanf还要nb的输入是getchar(),这个读入速度极快,输入挂就是基于这点写的。整数View Code inline bool scan_d(int &num) { char in;bool IsN=false; in=getchar(); if(in==EOF) return false; while(in!='-'&&(in<'0'||in> 阅读全文
posted @ 2012-05-29 12:22 LegendaryAC 阅读(2867) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1677这道题纠结了N个小时,因为原来找的模板里少了两个等号。。。结果就是错在了我一直觉得不会错的LIS里,让我认清了上升和非降的区别?下降数列的个数等于LIS,和导弹拦截那道题基本一致ps:连着三道LIS看排名都进了前三,好开心~View Code #include <iostream>#include <algorithm>using namespace std ;int dp[10001],p[20001];typedef struct L{ int w,h;}L;L kk[200 阅读全文
posted @ 2012-05-29 12:07 LegendaryAC 阅读(457) 评论(0) 推荐(0) 编辑