摘要: 题目地址:https://www.nowcoder.com/acm/contest/136/C dfs找出最长路和次长路,将两个结果相加再加上起点即可; 阅读全文
posted @ 2018-08-22 21:48 liubilan 阅读(212) 评论(0) 推荐(0)
摘要: 给出前几项,求出第n项; 阅读全文
posted @ 2018-08-22 20:50 liubilan 阅读(276) 评论(0) 推荐(0)
摘要: 题目地址:https://www.nowcoder.com/acm/contest/136/J 解法一: 推数学公式求前n项和; 当k=1时,即为等差数列,Sn = n+pn(n−1)/2 当k≠1时,an+p/(k−1) = k(an−1+p/(k-1)),等比数列,Sn = (kn+1+(p−1 阅读全文
posted @ 2018-08-22 20:03 liubilan 阅读(230) 评论(0) 推荐(0)
摘要: 题目地址:http://www.51cpc.com/web/problem.php?id=4286 解法 1: 解法 2:机智的解法 解法 3:这个简直超神了。。看到这个瞬间就清醒了,就是求4的多少次,特判下0的情况就行; 阅读全文
posted @ 2018-08-21 11:30 liubilan 阅读(207) 评论(0) 推荐(0)
摘要: 题目链接:https://www.luogu.org/problemnew/show/P2252 应用结论即可,证明参考:https://www.cnblogs.com/zwfymqz/p/8469863.html#_label0 阅读全文
posted @ 2018-08-18 17:06 liubilan 阅读(91) 评论(0) 推荐(0)
摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1846 经典基础博弈,首先面对(m+1)的人一定会输,依次往后推即可; 阅读全文
posted @ 2018-08-18 12:08 liubilan 阅读(129) 评论(0) 推荐(0)
摘要: 题目地址:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1057&judgeId=605203 使用压位进行优化,即一位数存多位数,例如当设置MOD=1e8时,一位数可以存8位数; 其次,注意尾数0,因为压位,一位需要输出 阅读全文
posted @ 2018-08-13 22:01 liubilan 阅读(244) 评论(0) 推荐(0)
摘要: 题目地址:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1021 经典区间dp,dp[i][j] 表示将从 i 到 j 堆石子合并最小代价,长度为 j-i+1,可看做之前已经合并的 i 到 k 和 k 到 j 两堆石子合并 阅读全文
posted @ 2018-08-13 15:58 liubilan 阅读(179) 评论(0) 推荐(0)
摘要: 1001 degree 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=6380 并查集向图中加点,分别记录与初始度数最多的点 直接相连的点数、独立的点数;则间接相连的点数 = n-1-直接相连的点数; 1004 p1m2 题目地址:http://acm 阅读全文
posted @ 2018-08-13 10:48 liubilan 阅读(242) 评论(0) 推荐(0)
摘要: 题目地址:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1013 Konwledge Point: 快速幂:https://www.cnblogs.com/liubilan/p/9450568.html 除法取模:(a/b 阅读全文
posted @ 2018-08-12 22:02 liubilan 阅读(181) 评论(0) 推荐(0)