博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Travelling
阅读量:5009 次
发布时间:2019-06-12

本文共 1101 字,大约阅读时间需要 3 分钟。

Description
After coding so many days,Mr Acmer wants to have a good rest.So travelling is the best choice!He has decided to visit n cities(he insists on seeing all the cities!And he does not mind which city being his start station because superman can bring him to any city at first but only once.), and of course there are m roads here,following a fee as usual.But Mr Acmer gets bored so easily that he doesn't want to visit a city more than twice!And he is so mean that he wants to minimize the total fee!He is lazy you see.So he turns to you for help.
Input
There are several test cases,the first line is two intergers n(1<=n<=10) and m,which means he needs to visit n cities and there are m roads he can choose,then m lines follow,each line will include three intergers a,b and c(1<=a,b<=n),means there is a road between a and b and the cost is of course c.Input to the End Of File.
Output
Output the minimum fee that he should pay,or -1 if he can't find such a route.
SampleInput
2 11 2 1003 21 2 402 3 503 31 2 31 3 42 3 10
SampleOutput
100907

转载于:https://www.cnblogs.com/to-creat/p/5005083.html

你可能感兴趣的文章
Cocos2dx 3.0 过渡篇(二十五)死不了的贪食蛇(触摸版)
查看>>
XPath定位时,使用文本的方法小技巧。
查看>>
EBS 信用检查(二)
查看>>
JZOJ 1781. Number
查看>>
.NET学习杂记
查看>>
高光导航、文字模糊
查看>>
nhibernate3 linq的where操作
查看>>
centos下Elasticsearch数据迁移与备份
查看>>
设置进程和线程的优先级
查看>>
android studio环境下创建menu问题(标题栏显示问题)
查看>>
MVC其实很简单(Django框架)
查看>>
UIScrollView 原理
查看>>
linux在tomcat中指定jdk
查看>>
vue学习(二)Vue常用指令
查看>>
《中国作者英文科学写作中的常见语法问题(一)》
查看>>
如何撰写SCI论文的讨论部分?——经典结构 – 俗称“倒漏斗型。
查看>>
织梦dedeCMS数据库结构字段说明-简略说明
查看>>
Cocoa touch(二):UIApplication
查看>>
【数据结构与算法C】利用两个栈S1S2模拟一个队列,用栈的基本操作实线EnQueue,DeQueue,QueueEmpty ...
查看>>
Python-编码和二进制-运算符
查看>>