编程介的小学生
2019-02-24 11:37符号序列的一次遍历算法ON的问题,利用C语言的编程技术解决
Problem Description
After a long drastic struggle with himself, LL decide to go for some snack at last. But when steping out of the dormitory, he found a serious problem : he can't remember where is the canteen... Even worse is the campus is very dark at night. So, each time he move, he check front, back, left and right to see which of those four adjacent squares are free, and randomly walk to one of the free squares until landing on a canteen.
Input
Each case begin with two integers n and m ( n<=15,m<=15 ), which indicate the size of the campus. Then n line follow, each contain m characters to describe the map. There are 4 different type of area in the map:
'@' is the start location. There is exactly one in each case.
'#' is an impassible square.
'$' is a canteen. There may be more than one in the campus.
'.' is a free square.
Output
Output the expected number of moves required to reach a canteen, which accurate to 6 fractional digits. If it is impossible , output -1.
Sample Input
1 2
@$
2 2
@.
.$
1 3
@#$
Sample Output
1.000000
4.000000
-1
- 点赞
- 回答
- 收藏
- 复制链接分享
0条回答
为你推荐
- Go语言中的地图序列化和反序列化问题
- it技术
- 互联网问答
- IT行业问题
- 计算机技术
- 编程语言问答
- 1个回答
- 利用c语言,写出顺序列表完成基础功能()
- c语言
- c++
- 1个回答
- 给一个整数x将该数插入到序列中,并使新的序列仍然有序,如何C语言
- r语言
- Golang
- erlang
- 2个回答
- 一个序列方面计算的问题,怎么对序列求和,用C语言
- r语言
- Golang
- 1个回答
- C++语言编程 运用贪心算法的方法
- 算法
- 编程
- c++
- 4个回答