这个问题的程序 [英] program for this question

查看:64
本文介绍了这个问题的程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的杰克是非常喜欢他的女朋友,Jilly的。他已经准备好去M英里去见Jilly了,他知道Jilly喜欢惊喜。


知道Jilly喜欢惊喜。因此,他决定在途中为她买一些好吃的东西



并在他的钱包中以R卢比出发。



在途中,杰克找到了四种类型的商店。商店以及每件商品的最低费用


如下:



连衣裙 - 卢比。 2000



鞋子 - 1000卢比



巧克力 - 500卢比



鲜花 - 500卢比



杰克想给吉利尽可能多的礼物,所以他不愿意花更多的钱/>


比每个商店的最低金额还要他们更喜欢买两个不同的



相同成本的物品而不是花的地段上购买更多的相同项目。



从Jack的位置到Jilly的地图,你被要求帮Jack决定哪个



方式去,这样他就可以为Jilly拿到最多的好吃的东西,然后尽可能快地到她那里来。



输入:



第一行输入表示测试用例的数量T.每行的第一行



testcase有两个以空格分隔的值R和M.第二行定义了代表地图的



矩阵NxM。以下N行定义了2D数组



代表从Jack的位置到Jilly的地图。礼服代表



by D,Shoes by S,Choloates by C和Flowers by F; J和Jilly by G.的杰克。



假设从地图上的一个街区移动到其相邻的街区将覆盖


距离1英里。



输出:



第一行输出应该代表杰克的行驶里程数



旅行。第二行显示他访问的所有不同块



,如示例输出中所示。如果Jack无法见到Jilly,请打印-1。



机密:rapidBizApps筛选问题集。



未经rapidBizApps事先书面许可,不得分享/分发



样本输入:



2



3000 10



5 7



J #####



## D1#C1 ##



# ##### G



## C2 ## F1#



##### #$



样品输出:



10



J ######



| - D1#C1 ##



## | ### G



## C2 - - F1 |



#######

Jack is very fond of his girlfriend, Jilly. He is ready to go M miles to meet Jilly, and he

knows Jilly loves surprises. So, he decides to pick up some goodies for her on his way

and sets out on this journey with R rupees in his wallet.

On his way, Jack finds shops of four types. The shops along with the minimum cost of

each item is given below:

Dresses - Rs. 2000

Shoes - Rs.1000

Chocolates - Rs.500

Flowers - Rs.500

Jack wants to give Jilly as many gifts as possible, so he is reluctant to spend more

than the minimum amount at each shop and he would prefer to buy two different

items of the same cost rather than spend the lot on buying more of the same item.

Given a map from Jack's location to Jilly's, you are asked to help Jack decide which

way to go, such that he can pick up maximum number of goodies for Jilly and get to

her as fast as possible.

Input :

The first line of input denotes the number of testcases T. The first line of each

testcase has two space-separated values R and M. The second line defines the

matrix NxM which represents the map. The following N lines define the 2D array

which represents the map from Jack's location to Jilly's. Dresses are represented

by D, Shoes by S, Choloates by C and Flowers by F; Jack by J and Jilly by G.

Assume that moving from one block on the map to its adjacent block covers a

distance of 1 mile.

Output :

The first line of output should represent the number of miles that Jack has

travelled. The second line follows to display all the different blocks that he visited

as shown in the sample output. Print -1 if it is not possible for Jack to meet Jilly.

Confidential: rapidBizApps Screening Problem-Set.

Do not share/distribute without prior written approval from rapidBizApps

Sample Input :

2

3000 10

5 7

J # # # # # #

# # D1 # C1 # #

# # # # # # G

# # C2 # # F1 #

# # # # # # #

Sample Output :

10

J # # # # # #

| - D1 # C1 # #

# # | # # # G

# # C2 - - F1 |

# # # # # # #

推荐答案

我们仍然不做你的作业:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!



如果遇到具体问题,请询问相关问题,我们会尽力提供帮助。但我们不打算为你做这一切!
We still do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!


这篇关于这个问题的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆