随笔分类 - acm--51 nod
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1393这题解法很奇妙。也是看了别人的思路才想出来.首先考虑把0全部变成-1。然后统计一个前缀和,用sum[i]表示.那么从起点开始的子串是合法的只要sum[i]的值等于0即可...
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1035因为结果要么是有限小数要么是无限循环小数,那么只要模拟这个过程,然后判断循环就跳出,记录循环次数就好。 1 #include 2 #include 3 #inclu...
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1119考虑从(1,1)->(n,m)必定会向下走n-1步,向右走m-1步,那么总的走法是C(n-1+m-1,m-1)。关于组合数取模:大神博客:http://blog.csd...
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1100首先按x坐标排序,然后相邻的三个点A,B,C 组成的三条直线必然有K(AC) 2 #include 3 #include 4 #include 5 #includ...
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1127可以用一个映射,把从头到当前位置的出现了多少个不同的字符计算出来,不断向区间末尾推进,如果包含了A-Z就可以更新最短长度,然后把开头的字符减1,表示向前推进一位.这样就...
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1278因为圆心都在x轴上,把每个圆转化成线段后,按线段的起点排序,那么对于每个圆都要从后面找出起点大于当前圆转化成的线段终点的一个点,这个点之后的圆都会与当前圆相离.因为按起...
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1428开始一直题意理解错误.首先按照开始时间从小到大排序.其实只要维护一个结束时间的最小堆,每次比较开始时间和堆中最小时间的大小,如果比它大就放入堆中并且时间就要变成当前任务...
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1298求出圆心到三条线段的最短距离,然后判断是否有顶点在圆外,就把全部情况举出来。 1 #include 2 #include 3 #include 4 #in...
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1242 1 #include 2 typedef long long ll; 3 const int mod = 1e9+9; 4 struct Mat 5 { 6 ...
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1113这个题因为m比较大,所以不能递归求解,需要换成循环的形式. 1 #include 2 typedef long long ll; 3 const int mod = ...
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1010http://poj.org/problem?id=1338首先poj这题要找出第n个丑数,想到要打表,因为每一个丑数都是由前一个丑数*2或者*3或者*5得到,每次取3...
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1095竟然错了10次,最后还是用字典树搞过去的,不过这题解法很多,二分,哈希,STL,排序 都可以搞。字典树建树的时候保存节点出现的次数,因为可能大小写都有,所以开next[...
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1126http://acm.hdu.edu.cn/showproblem.php?pid=1005注意上面一题和下面一题的区别,上面A,B可能取负数,但是mod跟c++中%是...
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#problemId=1007¬iceId=15020求出n个数的和sum,然后用sum/2作为背包容量,让n个数去放,求出一个最大价值,那么这就是其中一组的和,另外一组的和就是sum-dp[s...
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1264三角形的有向面积:a.x*b.y+b.x*c.y+c.x*a.y - a.x*c.y - c.x*b.y - b.x*a.y;上面得到的即是以点A,B,C三点组成的三角...
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#problemId=1050¬iceId=13385参考:http://blog.csdn.net/acdreamers/article/details/38760805#include#in...
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1049令 dp[i]表示为以a[i]结尾的最大子段和,则 dp[i]=max(dp[i-1]+a[i],a[i]);包含a[i-1] : dp[i]=dp[i-1]+a[i]...
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1092这个题是poj-3280的简化版,这里只可以增加字符,设 dp[i][j] 为把以i开头j结尾的子串变为回文串的最少次数,if(s[i]==s[j]) dp[i][j]...
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1006参考博客 :http://blog.csdn.net/yysdsyl/article/details/4226630引进一个二维数组c[][],用c[i][j]记录X[...
阅读全文
摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1085http://hihocoder.com/problemset/problem/1038?sid=320857在N件物品取出若干件放在容量为W的背包里,每件物品的体积为...
阅读全文

浙公网安备 33010602011771号