上一页 1 ··· 52 53 54 55 56 57 58 59 60 ··· 70 下一页
摘要: 题目链接: "https://www.luogu.com.cn/problem/P1892" 题目大意: 告诉你一些朋友和敌人关系。 以及: 我朋友的朋友是我的朋友; 我敌人的敌人也是我的朋友。 求:最多有多少各团伙? 解题思路: 把每个点 $i$ 拆分成两个点 $i$ 和 $i+n$,其中 $i$ 阅读全文
posted @ 2020-02-21 11:56 quanjun 阅读(288) 评论(0) 推荐(0)
摘要: 题目链接: "https://www.luogu.com.cn/problem/P1396" 解题思路: 贪心思想,按照边的拥挤度从小到大合并两个点,每次合并之后判断 $s$ 和 $t$ 是否在一个集合中, 如果不在,则继续;如果在,就输出这条边的拥挤度并结束。 实现代码如下: 阅读全文
posted @ 2020-02-21 11:42 quanjun 阅读(220) 评论(0) 推荐(0)
摘要: 题目链接: "https://www.luogu.com.cn/problem/P2078" 解题思路: 执行两次并查集。 第一次计算和小明认识的男生数量 $cnt1$; 第二次计算和小红认识的女生数量 $cnt2$。 答案就是 $\min (cnt1, cnt2)$ 实现代码如下: 阅读全文
posted @ 2020-02-21 11:19 quanjun 阅读(240) 评论(0) 推荐(0)
摘要: 题目链接: "https://www.luogu.com.cn/problem/P1656" 解题思路: 枚举每一条边,假设这条边被删掉,然后用并查集判断剩下的 $m 1$ 条边能否让这个图连通。 实现代码如下: 阅读全文
posted @ 2020-02-21 09:50 quanjun 阅读(162) 评论(0) 推荐(0)
摘要: 题目链接: "https://www.luogu.com.cn/problem/P1455" 解题思路: 这道题目就是首先用并查集把属于同一个集合的物品合到一起,然后对每一个集合的物品做01背包。 实现代码如下: 阅读全文
posted @ 2020-02-20 22:42 quanjun 阅读(230) 评论(0) 推荐(0)
摘要: Power digit sum $2^{15} = 32768$ and the sum of its digits is $3 + 2 + 7 + 6 + 8 = 26$. What is the sum of the digits of the number $2^{1000}$? 幂的数字和 阅读全文
posted @ 2020-02-18 21:15 quanjun 阅读(312) 评论(0) 推荐(0)
摘要: Lattice paths Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bott 阅读全文
posted @ 2020-02-18 21:07 quanjun 阅读(308) 评论(0) 推荐(1)
摘要: Longest Collatz sequence The following iterative sequence is defined for the set of positive integers: n → n/2 (n is even) n → 3n + 1 (n is odd) Using 阅读全文
posted @ 2020-02-18 20:28 quanjun 阅读(346) 评论(0) 推荐(0)
摘要: Large sum Work out the first ten digits of the sum of the following one hundred 50 digit numbers. 大和 计算出以下一百个50位数的和的前十位数字。 解题思路 目前想到的就是用高精度加法模拟。 100个5 阅读全文
posted @ 2020-02-18 19:20 quanjun 阅读(524) 评论(0) 推荐(0)
摘要: 题目链接: "https://www.luogu.com.cn/problem/P1016" 解题思路(思路全部来自 "hongzy大神的博客" ): 思路: 1. 在起点加满油; 2. 到第i个加油站把油箱里价格 P[i]的油退了,换成价格为P[i]的油。 3. 每次烧油就找最便宜的油烧 实现:单 阅读全文
posted @ 2020-02-18 12:04 quanjun 阅读(293) 评论(0) 推荐(0)
上一页 1 ··· 52 53 54 55 56 57 58 59 60 ··· 70 下一页