Lruihao

Lruihao's Note

不怕萬人阻擋,只怕自己投降

Lruihao's Github chart

在线离线算法

1 在线算法在线算法是指它可以以序列化的方式一个个的处理输入,也就是说在开始时并不需要已经知道所有的输入。 在计算机科学中,一个在线算法是指它可以以序列化的方式一个个的处理输入,也就是说在开始时并不需要已经知道所有的输入。相对的,对于一个离线算法,在开始时就需要知道问题的所有输入数据,而且在解决一个问题

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

非常可乐 大家一定觉的运动以后喝可乐是一件很惬意的事情,但是 seeyou 却不这么认为。因为每次当 seeyou 买了可乐以后,阿牛就要求和 seeyou 一起分享这一瓶可乐,而且一定要喝的和 seeyou 一样多。但 seeyou 的手中只有两个杯子,它们的容量分别是 N 毫升和 M 毫升 可乐的体积为 S(S<101)毫升(正好装满一瓶) ,它们三个之间可以相互倒可乐(都

hdu-2612-Find a way(双 bfs)

Find a way 圣诞节要到了,坤神和瑞瑞这对基佬想一起去召唤师大峡谷开开车。百度地图一下,发现周围的召唤师大峡谷还不少,这对基佬纠结着,该去哪一个。坤神:我要去左边的这个(因为离自己比较近 哈哈~)。瑞瑞:我要去右边的这个(因为离自己比较近 嘿嘿~) …….. 这对基佬闹矛盾了,开车有危险了!为了不让他们去召唤师大峡谷坑人

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? 1 InputLine 1: Two space-separated integers: N and K 2 OutputLine 1: The least amount of time, in minutes, it takes for Farmer John to catch the fugitive

poj-2251-Dungeon Master(三维 bfs 最短路)

英文原题链接 1 Description - 题目描述你被困在一个三维的空间中,现在要寻找最短路径逃生! 空间由立方体单位构成 你每次向上下前后左右移动一个单位需要一分钟 你不能对角线移动并且四周封闭 是否存在逃出生天的可能性?如果存在,则需要多少时间? 2 Input - 输入输入第一行是一个数表示空间的数量。 每个空间的描述的第一行为 L,R 和 C(皆

poj-1321 棋盘问题(dfs)

Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 63659 Accepted: 30423 1 Description在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放 k 个棋子的所有可行的摆放方案 C。 2 Input输入含有多组测试数据。 每组数据的第一行是两

poj-1426-Find The Multiple(dfs)

1 Find The MultipleTime Limit: 1000MS Memory Limit: 10000K Total Submissions: 40713 Accepted: 17088 Special Judge 1.1 DescriptionGiven 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. 1.2 InputThe input file may contain multiple test cases. Each line contains a value of n (1 <= n <= 200). A line containing a zero terminates the input. 1.3 OutputFor each value of n in the input print a line containing the corresponding value of m. The decimal representation of m must not contain more than 100 digits. If there are multiple solutions for a given value of n, any one of them is acceptable. 1.4 Sample Input2 6 19 0 1.5

Adjacent Replacements

A. Adjacent Replacements 第一次打 cf 就做出一道这样的找规律的题,打到自闭。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #include<bits/stdc++.h> using namespace std; int main(){ int n,a[1001]; cin>>n; int i; int flag=0; for(i=0;i<n;i++){ cin>>a[i]; if(!(a[i]&1)) a[i]--; if(!flag) {cout<<a[i];flag=1;} else cout<<" "<<a[i]; } return 0; }

poj-3984-迷宫问题 (bfs 路径)

迷宫问题 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 32323 Accepted: 18471 1 Description定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, }; 它表示一个迷宫,其中的 1 表示墙壁,0 表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。 2 Input一个 5 × 5 的二维数组,表示一个

Wannafly 挑战赛 20-染色

链接:https://www.nowcoder.com/acm/contest/133/A 来源:牛客网 1 题目描述现在有一棵被 Samsara-Karma 染了 k 种颜色的树,每种颜色有着不同的价值,Applese 觉得 Samsara-Karma 染的太难看了,于是打算把整棵树重新染成同一种颜色,但是,由于一些奥妙重重的原因,每一次染色 Applese 可以选择两个有边相连
0%