![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
ACM & TCO
文章平均质量分 67
cg05568256068
没有天赋,只有热情和汗水。
展开
-
[dp问题] Poj 1014 & Zoj 1149 (Dividing) 解题报告(转)
Poj_1014 & Zoj_1149 (Dividing) 解题报告一.问题描述: 有价值分别为1..6的大理石各a[1..6]块,现要将它们分成两部分,使得两部分价值之和相等,问是否可以实现。其中大理石的总数不超过20000。 二.问题分析: 很明显是一个划分问题---分成等价值的两部分,进一步可以发现也是一个组合问题,即:第一部分选择哪些大理石,选择多少;第二部分则选择剩原创 2007-07-29 20:50:00 · 3245 阅读 · 4 评论 -
SRM 439 SquareOfDigits
题目链接:http://www.topcoder.com/stat?c=problem_statement&pm=10395&rd=13747这个题目比较简单,主要是看循环循序不同对算法效率的影响one:#include#includeusing namespace std;struct SquareOfDigits{ int min(int a,int b)原创 2009-05-11 14:44:00 · 496 阅读 · 0 评论 -
SRM 439 PouringWater
题目链接:http://www.topcoder.com/stat?c=problem_statement&pm=10408&rd=13747通过利用二叉树进行模拟发现,只要求n二进制里1的个数与k的大小关系即可7=4+2+1 对应二进制的个数是3#includeusing namespace std;struct PouringWater{ int coun原创 2009-05-11 15:19:00 · 713 阅读 · 0 评论 -
第一次TCO SRM440(纪念一下)
原创 2009-05-12 21:15:00 · 524 阅读 · 0 评论 -
SRM 440 总结
题目一:http://www.topcoder.com/stat?c=problem_statement&pm=10309解题思路:根据di = 1/2*g*(ti^2) 以第一个为参照,求得所有后面的与第一个的比例关系。然后根据sum(ti)=T 求出第一个的t1,再根据d1 = 1/2*g*(t1^2) 求出g后来看了别人的代码,发现有更简单的做法,首先对t开方出来。#incl原创 2009-05-13 20:42:00 · 675 阅读 · 0 评论 -
SRM 440 WickedTeacher (DP)
题目链接:http://www.topcoder.com/stat?c=problem_statement&pm=10289解题思路: n个数的permutation是建立在n-1个数的全排列的基础上,对每n-1个数的全排列后面不断的添加一个未用到的数。n个数的状态可以用0到2^n-1中的数bit来分别表示。dp[bit][mod],bit对应的二进制位为1,表示用到了该数,mo原创 2009-05-15 13:31:00 · 698 阅读 · 0 评论 -
pku 3735 Training little cats (矩阵幂乘)
题目来源:http://acm.pku.edu.cn/JudgeOnline/problem?id=3735解题思路:取向量b表示最后的结果,我这里对于n个数,构造n+1维的向量,目的是有利于后面的‘g’操作 对于每一次的操作用矩阵表示,这里的矩阵a是(n+1,n+1),初始化为一个单位矩阵‘g’ num 操作,表示使第num个数增加1,使矩阵a的第num行最后一个元素增加1,原创 2009-05-17 19:39:00 · 1207 阅读 · 3 评论 -
TCO'09 Elimination Round 2 PlaneFractal recursion
题目链接:http://www.topcoder.com/stat?c=problem_statement&pm=10333//递归的整体思想 宏观看微观#include #include #include using namespace std;struct PlaneFractal{ char check(int s, int N, int K, int x,原创 2009-05-18 21:44:00 · 548 阅读 · 0 评论 -
pku 3737 UmBasketella (含推导过程)
题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=3737推导过程:程序代码:#include#includeconst double pi=3.1415926;int main(){ double s; while(scanf("%lf",&s)!=EOF) { double r=sqrt(s原创 2009-05-17 16:04:00 · 798 阅读 · 0 评论 -
TCO09 Round 1 KthProbableElement (dp或者 概率统计)
题目链接:http://www.topcoder.com/stat?c=problem_statement&pm=10335题目大体意思:在区间[lower,upper]中间取m个数,使得这m个数中第k小的数是n的概率解法一:(强大的dp)参照别人解题报告写出来的dp[m][s][b] 取m个数,比n小的最多s个,比n大的最多b个的概率(注意最多二字)则dp[0][s原创 2009-05-18 21:42:00 · 637 阅读 · 0 评论 -
TCO09 ROUND 3 SaveTheTrees (枚举的优化+函数优化)
题目链接:http://www.topcoder.com/stat?c=problem_statement&pm=10361解题思路: 最开始我想通过对砍掉的树数从小到大进行枚举,最大可以达到2^40,枚举量太大了。 改变思路,通过枚举fence的大小,对fence外的和内的分别做处理,岂不是一个很好的思路。为了减少时间,可以在枚举前对tree按照height从大到小进行排原创 2009-05-20 15:07:00 · 488 阅读 · 0 评论 -
SRM 436 DigitsSwap (math)
题目链接:http://www.topcoder.com/stat?c=problem_statement&pm=10342题目大意:给定两个数x和y,通过对x和y某些位交换后,使得x*y的结果最大,交换次数给定解题思路:因为x和y对应位不管怎么交换,x+y的值保持不变,所以要使x*y最大,只要是x和y之间的距离最小就可以。如何寻找最小距离的x和y呢?首先假设x>y,从左到右扫描,找到第一原创 2009-05-22 14:53:00 · 478 阅读 · 0 评论 -
匹配问题(最大匹配,最小覆盖,最大独立集) 欢迎大家来讨论
以下是关于匹配问题的相关几个题目,大家只要把匈牙利算法的模板根据具体题目修改下就可以了匈牙利算法的模板:http://blog.csdn.net/cg05568256068/archive/2009/04/30/4140816.aspx Girls and Boys 最大独立集链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=1466原创 2009-05-01 10:11:00 · 1602 阅读 · 0 评论 -
二分图最大匹配 匈牙利算法 (自己写的模板)
以前做二分图最大匹配的时候,都是用别人的模板。今天认真的看了《实用算法分析与设计》关于这个的介绍,并自己写了个模板,感觉从中又学到了好多以前没弄清楚的东西。//二分图最大匹配 匈牙利算法//2009.4.30#include#includeconst int max_v = 500; //顶点数的上限,注:这里的二分图左右两边顶点个数相等const i原创 2009-04-30 21:09:00 · 1454 阅读 · 0 评论 -
[杂题] pku 2019
解题报告: Cornfields Lcftc 题目类型:搜索,简单,PKU2019题 一、 题目: Cornfields Description FJ has decided to grow his own corn hybrid in order to help the cows make the best possible milk. To that end, hes looking to原创 2007-07-29 21:54:00 · 939 阅读 · 0 评论 -
[dp问题] pku 2295
//此题做起来不怎么难,有点类似表达式的计算算法,考虑的方面可多,调试比较麻烦,遇到wa的时候,要有耐心#include#include#includechar a[270];int main(){ int m,x,xx,yy,i,j,f,len,k,flag; scanf("%d",&m); for(k=0;k { getchar(); scanf("%s",a); f=0; len原创 2007-08-01 19:59:00 · 654 阅读 · 1 评论 -
[数学题] pku 3472 Holey Square Tiling
首先介绍本题的解题思想:分类思想,化繁为简。善于从复杂问题中抽象出自己熟悉的模型进行解决。http://www.math.unam.mx/EMIS/journals/JIS/VOL7/Tauraso/tauraso3.pdf的解题报告对我的作用很大。刚开始我按照poj monthly contest解题报告的思想,列出了本题的递推关系,并自己进行程序的编写,发现很是麻烦,并且提交给了我一原创 2009-01-21 11:37:00 · 993 阅读 · 0 评论 -
[模拟题] 利用STL中string解pku 1068
DescriptionLet S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways: q By an integer sequence P = p1 p2...pn where pi is the number of left parentheses befo原创 2009-02-26 22:03:00 · 616 阅读 · 0 评论 -
[杂题] pku 1338 ugly numbers (STL解)
Ugly NumbersDescriptionUgly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, ... shows the first 10 ugly numbers. By convention, 1 is inc原创 2009-03-08 17:20:00 · 859 阅读 · 0 评论 -
[dp问题] Girl Love Value(dp问题)hdu2670
Problem Description Love in college is a happy thing but always have so many pity boys or girls can not find it.Now a chance is coming for lots of single boys. The Most beautiful and lovely and i原创 2009-03-09 15:03:00 · 899 阅读 · 0 评论 -
[数学题] Sorting by Swapping pku 1674
Sorting by SwappingDescriptionGiven a permutation of numbers from 1 to n, we can always get the sequence 1, 2, 3, ..., n by swapping pairs of numbers. For example, if the initial sequence is 2,原创 2009-03-09 21:08:00 · 1262 阅读 · 1 评论 -
SRM 437 TheSwap ( Permutation + Memory Search )
My idea: At first I solve this problem with the greedy approach (keeping the number maximal for every iteration) and all the test cases given is right . Later on I find some cases from the dis原创 2009-04-09 16:05:00 · 640 阅读 · 0 评论 -
Hiking Trip 08年杭州赛区网络预选赛
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2425 解题思路: 开始时直接用DFS和BFS都写了一次,并增加有一点剪枝,仍然是超时或者超内存。因为再20*20的范围下,复杂度可以达到 4^20 ,这样时肯定过不了的。 改进方法一:离散化 + BFS 对time T(x)进行离散化,将其分解为 used + remai原创 2009-04-29 14:57:00 · 644 阅读 · 0 评论 -
A*路径搜索算法入门
翻译后链接:http://zone.emsky.net/?uid-2-action-viewspace-itemid-118原文链接:http://www.gamedev.net/reference/articles/article2003.asp原作者文章链接:http://www.policyalmanac.org/games/aStarTutorial.htm原创 2009-04-29 16:22:00 · 545 阅读 · 0 评论 -
二维树状数组 hdu 1892
简单的一个二维树状数组的应用,没有变形题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1892//二维树状数组//#includeconst int size = 1002;int C[size][size];int D[size][size];int lowbit(int n){ return n原创 2009-05-05 19:32:00 · 1071 阅读 · 0 评论 -
MagicSource(数学类)-由数到位,效率质的变化
/***author:steel 2009-10-23srm451 MagicSource 解题思路: 解法一:利用枚举法,最后发现对某些数据超时 eg:999999999988->909090908 解法二:即本程序解法,不是对数进行枚举,而是对数的为数进行枚举,这样枚举量发生了质的飞跃, 2^64=18446744073709551616 还不到20位,然后对确定的位数,从低位到高位进行推原创 2009-10-23 18:03:00 · 1304 阅读 · 0 评论