java 邮递员类型问题 高手赐教

问题描述

PenPlotterProblemBeforetheadventofinkjetandlaserprinters,straightlinedrawingsusedtobeplottedbycolouredpensonlargesheetsofpaper:thepensmovedveryslowlysothiswasatime-consumingprocess.Sincetimeismoney,itwasimportanttodrawfiguresinanoptimalway,usingminimumtime.Inthisassignment,youwillimplementanA*searchprocedureforthepenplotterproblem(withonlyonecolouredpentomakeitsimple,thoughintherealproblem,therewouldbemultiplepenswhichwouldhavetobechangedmanually,costingevenmoretime).[Acontemporaryrelatedproblemisthatofabicyclecourierwhohastopickupmultiplepacketsanddeliverthemtotheirdestinationsaroundthecityinminimumtime,butthisisamuchharderproblemtosolve.]Inyourprogramdesign,makeuseoftheStrategypatterntosupplyaheuristictothesearchprocedure,anddon'tforgettoensurethatyourheuristicisadmissible.Thepapersheetisunderstoodtobelaidoutonagridwithboththex-axisandy-axisrunningfrom0uptoinfinity(notionally).Alldrawingsarefullycontainedinthisquadrantandcanbeassumedtofitonthepage.Linescanalwaysbeassumednottobecontainedinotherlines.Thepenalwaysstartsattheorigin(0,0)butcanfinishanywhere.Linesarespecifiedbythe(x,y)coordinates(inintegers)oftheirendpointsonthegrid.Thepencaneitherdrawalinebetweenanytwopointsormove(withoutdrawinganything)inastraightlinebetweenanytwopoints.Asshouldbeobvious,alinecanbedrawnineitherdirection.Sincewewanttominimizethetotaltimetodrawafigure,assumethepenmovesatconstantspeedsothatanoptimaldrawingisonethatminimizesthetotaldistancemovedbythepenwhilstnotdrawing.Allinputwillbeinafilewithasequenceoflinesofthefollowingform:Linebetween<x1><y2>and<x2><y2>#specifythatthedrawingcontainsalinebetweenthepoints(<x1,y1>)and(<x2>,<y2>)CallyourmainJavafilePenPlotter.java.ReadinputfromafilewhosenameispassedasanargumenttothemainmethodinthecalltojavaPenPlotterandprintoutputtoSystem.out.Formachinemarking,theoutputwillberedirectedtoatextfilethatwillbecomparedtotheexpectedoutput(sodonotprintoutextraspaces,etc.).Forthepurposesofmachinemarking,drawingswillbeusedforwhichthereisonlyoneoptimalsolution,thoughinthecaseofmultipleoptimalsolutions,yourprogramshouldproduceoneofthem.Tohandleinputfromatextfile,asinAssignment1,useJavacodesuchas:try{Scannersc=newScanner(newFileReader(args[0]));#args[0]isthefirstcommandlineargument}catch(FileNotFoundExceptione){}SampleInputForexample,thefollowinginputshoulddrawasimplestarshapedfigurewithsixlinesradiatingfromthepoint(4,4).Theformatandmeaningoftheinputisasfollows(commentsareforexplanationandwillnotappearintheactualinput):Linebetween41and44#thereisalinebetween(4,1)and(4,4)Linebetween44and47#thereisalinebetween(4,4)and(4,7)Linebetween26and44#thereisalinebetween(2,6)and(4,4)Linebetween44and62#thereisalinebetween(4,4)and(6,2)Linebetween66and44#thereisalinebetween(6,6)and(4,4)Linebetween22and44#thereisalinebetween(2,2)and(4,4)SampleOutputTheoutputcorrespondingtotheaboveinputisasfollows(thefirstlineintheoutputshouldindicatethenumberofnodesexploredinthesearch,whichofcoursewillvaryaccordingtotheheuristicused):<n>nodesexploredMovefrom00to22Drawfrom22to44Drawfrom44to66Movefrom66to47Drawfrom47to44Drawfrom44to41Movefrom41to62Drawfrom62to44Drawfrom44to26大意就是给定一些点,并告诉这些点之间哪些要用线连起来,用笔画线,是笔的移动距离最短跪求解题思路

时间: 2024-07-31 19:28:17

java 邮递员类型问题 高手赐教的相关文章

java中 Integer a=5;和Integer a = new Integer(5);的区别?请高手赐教。

问题描述 java中 Integer a=5;和Integer a = new Integer(5);的区别?请高手赐教. /*首先要知道的常识:1.关系操作符==:计算""操作数""的 值 之间的关系,结果为true或者false;这操作数指的是所有的基本数据类型以及所有对象;2.equals():是Object类中的方法,equals()作用和==相同,但是不适用于基本数据类型:3.自己定义的类可以覆盖Object类中的equals(); *///下面来看一个例

vsm-利用java建立VSM模型时,矩阵太大应该怎么办?普通的增大内存都不管用了!!请高手赐教

问题描述 利用java建立VSM模型时,矩阵太大应该怎么办?普通的增大内存都不管用了!!请高手赐教 利用java建立VSM模型时,矩阵太大应该怎么办?普通的增大内存都不管用了!!请高手赐教 解决方案 挖掘机技术哪家强,中国山东找蓝翔 内存不够怎么办,电脑硬盘找办法 解决方案二: 你是在windows开发的吧?windows的JVM有最大内存限制,不同系统不同,单纯修改最大内存 -Xmx是没效果的.具体最大内存大小建议自己测试. 如果是在linux开发,内存不够的情况下,建议用持久化的办法.如何持

定时同步数据求教-java接口定时同步数据有好的解决方案吗?数据量可能上万或上十万条,求高手赐教

问题描述 java接口定时同步数据有好的解决方案吗?数据量可能上万或上十万条,求高手赐教 我调别人的接口,要每天一次定时把对面的数据同步到我们的(oracle)数据库里,之前没做过类似的,现在想法是每条数据都先查询一下,存在就跟新,不存在就插入..但是感觉这样数据库压力大吗,请问有别的好的想法吗?大神快来..还没有C币,谢谢了 解决方案 这么大量的数据,建议你打包成文件然后下载. 解决方案二: oracle不是有merge吗?不用先查询的 解决方案三: 1.先把数据全部取过来放到一张临时表中 2

关于android 横竖屏的一个问题。求高手赐教。

问题描述 关于android 横竖屏的一个问题.求高手赐教. 关于android 横竖屏的一个问题.求高手赐教. activity被我强制设为横屏了,但是在此activity上锁屏后再解锁屏,这时此activity竟是从竖屏切换到横屏了,也就是说锁屏后横屏的activity又变回竖屏了.这是怎么回事?如何让被我强制设为横屏的activity一直保持横屏,即使在锁屏的时候? 解决方案 其实我很奇怪为什么你的屏幕没有转成横屏,因为你已经设置横屏了. 如果一个界面是横屏状态下锁屏,如果锁屏界面是竖屏,

c c++-求用c编写的一个简单的爬虫程序,高手赐教,不胜感激

问题描述 求用c编写的一个简单的爬虫程序,高手赐教,不胜感激 本人是初学者,要编写一爬虫程序,抓取60多万个网页上的信息,实在是无从下手,请高手给一个能看得懂的简单的爬虫程序学习用,多谢 解决方案 我也要写一个C爬虫,不过遇到了一些问题,比如58这样的网站,用getaddrinfo返回的ip无法连接,已经耽误了我好几天了,别的问题到还没遇到

c++-怎么按下ESC键没有任何反应?请高手赐教

问题描述 怎么按下ESC键没有任何反应?请高手赐教 #define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0) if(KEY_DOWN(VK_ESCAPE)) PostMessage(hwnd,WM_DESTROY,0,0); 解决方案 重载虚函数: BOOL CdlgTotal::PreTranslateMessage(MSG* pMsg) { if(pMsg->message==WM_KEYDOWN &

用户无法收到-微信 被动回复视频信息问题,急需各位高手赐教!

问题描述 微信 被动回复视频信息问题,急需各位高手赐教! 我按照开发文档的xml格式,在用户发送小视频给公众号时,让公众号把刚才发送的视频回复给用户.可是一直遇到一个问题,我按照接收到xml数据提取了了视频的格式.media_id,thumbMedia_id,title等信息,重组xml数据回复,结果无论怎么样用户都没有收到回复的视频信息!而测试其他包括文字.语音.音乐.图文.图片信息都能够实现.急需高手赐教! 解决方案 在本地测试一下返回给微信服务器的xml格式跟开发文档中是否一致,注意大小写

回溯 搜索 数独 pascal 求高手赐教

问题描述 回溯 搜索 数独 pascal 求高手赐教 我的代码 请问那里有问题 答案总是错 谢谢 靶形数独 (sudo.pas/c/cpp) [问题描述] 小城和小华都是热爱数学的好学生,最近,他们不约而同地迷上了数独游戏,好胜的他们想用数独来一比高低.但普通的数独对他们来说都过于简单了,于是他们向Z博士请教,Z博士拿出了他最近发明的"靶形数独",作为这两个孩子比试的题目. 靶形数独的方格同普通数独一样,在9格宽×9格高的大九宫格中有9个3格宽×3格高的小九宫格(用粗黑色线隔开的).在

unicode编码-在三星S4行开发Android应用遇到一个Unicode编码的问题,请高手赐教,非常感谢

问题描述 在三星S4行开发Android应用遇到一个Unicode编码的问题,请高手赐教,非常感谢 从服务器端获取unicode字节数组,打印出来为003300300030003300300031,从打印来看应该小端UTF-16格式,对应字符串300301,但是用String(byteArrayUTF-16LE"")还是encodingUtls.getString(byteArrayUTF-16LE"")都是乱码,请问这个问题怎么解决,谢谢~~