Lruihao

Lruihao's Note

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

Lruihao's Github chart

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 可以选择两个有边相连

hdu-1241-Oil Deposits (dfs)

1 Oil Deposits翻译 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 41406 Accepted Submission(s): 23977 1.1 Problem DescriptionThe GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides the land into numerous square plots. It then analyzes each plot separately, using sensing equipment to determine whether or not the plot contains oil. A plot containing oil is called a pocket. If two pockets are adjacent, then they are part of the same oil deposit. Oil deposits can be quite large and may contain numerous pockets. Your job is to determine how many different oil deposits are contained in a grid. 1.2 InputThe input file contains one or more grids. Each grid begins with a line containing m and

BFS 求最短路

假设有一个 n 行 m 列的迷宫,每个单位要么是空地(用 1 表示)要么是障碍物(用 0 表示).
如和找到从起点到终点的最短路径?利用 BFS 搜索,逐步计算出每个节点到起点的最短距离,
以及最短路径每个节点的前一个节点。最终将生成一颗以起点为根的 BFS 树。此时 BFS 可以求出任意一点到起点的距离。

Educational Codeforces Round 47 (Rated for Div. 2)

那天晚上报名了没打,第二天早上打的,也只出了两题。 1 A. Game Shopping 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 #include<iostream> using namespace std; int main(){ int n,m,s=0; cin>>n>>m; int i,j; int c[1000],a[1000]; for(i=0;i<n;i++) cin>>c[i]; for(i=0;i<m;i++) cin>>a[i]; for(i=0,j=0;i<n;){ if(j==m) break; if(c[i]<=a[j]){ s++; j++; i++; } else i++; } if(i==n&&s==0) cout<<"0\n"; else cout<<s<<endl; return 0; } 2 B. Minimum Ternary String 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 #include <bits/stdc++.h> using namespace std; string s, ans; int main(){ cin >> s;
0%