03 2014 档案
摘要:做了三个题,先贴一下代码。。。终于涨分了A. Line to Cashier水题 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 const int INF = (1>n)15 {16 Min = INF;17 for(i = 0; i >a[i];19 for(i = 0; i >b;26 ans += b*5;27 }28 ...
阅读全文
摘要:题目链接题意:给n个数字, 求有k个数字的上升子序列有多少种。思路:d[i][j]表示 以第i个元素为 子序列的最后一个元素,长度为j的子序列 有多少种。比赛的时候 光想着用组合数做了。。。。。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int maxn = 110; 8 9 __int64 d[maxn][maxn];10 int a[maxn];11 int main()12 {13 __int64 ans;14 int k, i, ...
阅读全文
摘要:题目链接题意:n个人, 要完成a个x任务, b个y任务。求,最短的时间思路:由于时间较大,用 二分来找时间。dp[i][j]表示 i个人完成j个x任务, 最多能完成的y任务个数这个题 不是很好想, 还参考了一下大神的博客 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int maxn = 1000+10; 8 int d[55][205]; 9 10 int _max(int a, int b)11 {12 return a>b?a:b;13 }14 ...
阅读全文
摘要:也是比赛时候的一道题目, 但是这么构造,超时,不过也是一个构造字符串的好的程序。贴一下模板的吧s[]数组,刚开始是 输入一个字符串,get()函数的作用是 按照字典序,依次构造这个字符串,并存储在s[]数组中.直到所有的字符串构造 完成。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int N=1050; 8 char s[N]; 9 int l;10 int get()11 {12 int i = l-1;13 while(i>0&&s[i..
阅读全文
摘要:题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2831题意:给a, b, c, d, e, f 6个点abgh是平行四边形。def是三角形。面积相等。求点 g, h的坐标思路:1. DE*DF/2 = AH*AB; (向量DE叉乘向量DF,除以2, 等于 向量AH叉乘 AB)2. AH = k AC; (向量AH 等于 k倍的向量AC)将2式代入1式。就可以求得。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #in.
阅读全文
摘要:转载自http://blog.csdn.net/william001zs/article/details/6213485矢量 如果一条线段的端点是有次序之分的话,那么这种线段就称为 有向线段,如果有向线段p1p2的起点p1在坐标的原点,则可以把它称为矢量 p2矢量的加减 设二维矢量 P = (x1,...
阅读全文
摘要:题目:http://acm.fzu.edu.cn/problem.php?pid=2148题意:给出n个点,判断可以组成多少个凸四边形。思路:因为n很小,所以直接暴力,判断是否为凸四边形的方法是:如果4个点中存在某个点D,Sabd + Sacd + Sbcd = Sabc,则说明是凹四边形。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 const double eps = 1e-8; //定义成double类型 9 10 struct poin...
阅读全文
摘要:题目:http://acm.fzu.edu.cn/problem.php?pid=2140题意:题目大意:给出n,要求找出n个点,满足:1)任意两点间的距离不超过1;2)每个点与(0,0)点的距离不超过1;3)有n对点之间的距离刚好为1;4)n个点组成的多边形面积大于0.5;5)n个点组成的多边形面积小于0.75;思路:只要有4个点以上就是,构造时先找出四个点,再在半径为1的圆上找点就行。很巧妙的一道题目呀、、、、 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace ...
阅读全文
摘要:题目:http://codeforces.com/contest/404/problem/B 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 int main() 9 {10 __int64 g; //g一定要是长整形,因为数据会超int.这个也是错误的最主要原因11 int n, i;12 double a, d, x, y, sum, cnt;13 while(~scanf("%lf%lf%d", &a, &d, &n))14 ..
阅读全文
摘要:题目:http://poj.org/problem?id=3258题意:一条河长度为 L,河的起点(Start)和终点(End)分别有2块石头,S到E的距离就是L。河中有n块石头,每块石头到S都有唯一的距离问现在要移除m块石头(S和E除外),每次移除的是与当前最短距离相关联的石头,要求移除m块石头后,使得那时的最短距离尽可能大,输出那个最短距离。和3273差不多。。。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int maxn = 50000+10; 8 ...
阅读全文
摘要:题目:http://poj.org/problem?id=1067题意:有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目...
阅读全文
摘要:题目:http://poj.org/problem?id=3273题意:把n个数分成m份,使每份的和尽量小,输出最大的那一个的和。思路:二分枚举最大的和,时间复杂度为O(nlog(sum-max));一道很好的题。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int maxn = 100000+10; 8 int a[maxn]; 9 10 int main()11 {12 int n, m, i, Max, sum;13 while(~sc...
阅读全文
摘要:题目:http://codeforces.com/contest/401/problem/C题意:n个0,m个1,求没有00或111的情况。这么简单的题。。。。。做题的时候脑残了。。。,今天,贴一下ac的代码,警示一下自己 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 int main() 9 {10 int n, m;11 int i;12 while(cin>>m>>n)13 {14 15 if(n>=m-1&&(...
阅读全文
摘要:题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3607题意:一个卖面包的小姑娘,给第i个来买面包的人的价格是pi, 每个人的时间是ti,问用最小的时间间隔 求最大的平均值。刚开始没有 考虑,后一个的时间间隔要大于之前的最大的时间间隔 才行。。。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int maxn = 1000+10; 8 const int INF = 1 tty)3...
阅读全文
摘要:题目:http://poj.org/problem?id=1185思路:d[i][j][k]表示第i行的状态为第k个状态,第i-1行的状态为第j个状态的时候 的炮的数量。1表示放大炮, 地形状态中1表示山地。 1 #include 2 #include 3 #include 4 #includ...
阅读全文
摘要:题目:http://poj.org/problem?id=2411InputThe input contains several test cases. Each test case is made up of two integer numbers: the height h and the wi...
阅读全文
摘要:题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2819 1 #include 2 #include 3 #include 4 #include 5 #include 6 using nam...
阅读全文
摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=1421思路:d[i][j] 表示前i 个,k对的最小值。这个题还是不太好想状态方程,初始化以后,还要分一下情况。。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int maxn = 2000+10; 8 const int maxm = 1000+10; 9 const int INF = 1y?y:x;16 }17 int main()18 {19 int ...
阅读全文

浙公网安备 33010602011771号