Home avatar

Lruihao's Note

Lruihao's GitHub chart

畅通工程-HDU-1232(并查集经典模板)

并查集入门推荐:超有爱的并查集~

题目链接:畅通工程

题意分析

首先在地图上给你若干个城镇,这些城镇都可以看作点,然后告诉你哪些对城镇之间是有道路直接相连的。最后要解决的是整幅图的连通性问题。比如随意给你两个点,让你判断它们是否连通,或者问你整幅图一共有几个连通分支,也就是被分成了几个互相独立的块。像畅通工程这题,问还需要修几条路,实质就是求有几个连通分支。

HDU-1495-非常可乐(bfs 模拟倒水 or 数论)

非常可乐

大家一定觉的运动以后喝可乐是一件很惬意的事情,但是 seeyou 却不这么认为。因为每次当 seeyou 买了可乐以后,阿牛就要求和 seeyou 一起分享这一瓶可乐,而且一定要喝的和 seeyou 一样多。但 seeyou 的手中只有两个杯子,它们的容量分别是 N 毫升和 M 毫升 可乐的体积为 S(S<101)毫升(正好装满一瓶) ,它们三个之间可以相互倒可乐(都是没有刻度的,且 S==N+M,101 > S > 0,N > 0,M > 0) 。聪明的 ACMER 你们说他们能平分吗?如果能请输出倒可乐的最少的次数,如果不能输出"NO"。

Hdu-2612-Find a Way(双 Bfs)

Find a way

圣诞节要到了,坤神和瑞瑞这对基佬想一起去召唤师大峡谷开开车。百度地图一下,发现周围的召唤师大峡谷还不少,这对基佬纠结着,该去哪一个。坤神:我要去左边的这个(因为离自己比较近 哈哈~)。瑞瑞:我要去右边的这个(因为离自己比较近 嘿嘿~) …….. 这对基佬闹矛盾了,开车有危险了!为了不让他们去召唤师大峡谷坑人,riot 决定让他们去 X 召唤师大峡谷,保证他俩所走的路程和最短。每走一个点需要花费 11 分钟,输出他们一共花费多少时间(最短时间噢)

POJ-3278-Catch That Cow(bfs)

Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0 ≤ K ≤ 100,000) on the same number line. Farmer John has two modes of transportation: walking and teleporting.

  • Walking: FJ can move from any point X to the points X",“1 or X + 1 in a single minute
  • Teleporting: FJ can move from any point X to the point 2 × X in a single minute.

If the cow, unaware of its pursuit, does not move at all, how long does it take for Farmer John to retrieve it?

Input

Line 1: Two space-separated integers: N and K

Poj-1321 棋盘问题(dfs)

Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 63659
Accepted: 30423

Description

在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放 k 个棋子的所有可行的摆放方案 C。

Poj-1426-Find the Multiple(dfs)

Find The Multiple

Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 40713 Accepted: 17088 Special Judge

Description

Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there is a corresponding m containing no more than 100 decimal digits.

发现新版本

当前站点有新版本可用。