文件名称:TSP
- 所属分类:
- 控制台(字符窗口)编程
- 资源属性:
- [C/C++] [源码]
- 上传时间:
- 2016-05-08
- 文件大小:
- 5kb
- 下载次数:
- 10次
- 提 供 者:
- b***
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
描述
Traveling Salesman Problem
市场上有很多种商品,旅行商Shrek做短期买卖赚取差价。他从一个城市购买一件商品,到达下一个相邻的城市就卖掉。如果这一次买卖无利可图,那么他就不会这么走。凭着自己和同伴多年的经验,他已经对地图上n个城市之间的差价了如指掌。两城市间可能有多种商品可赚取差价,此时Shrek只好倒卖利润最大的一件商品。
现在请你帮Shrek规划一条路线,使他能赚最多的钱。
输入
第一行两个整数n、m。表示有n个城市,编号1~n
接下来有m行,每行三个整数a、b、price,表示从城市a到城市b可赚取差价price。
输出
若干Tab分隔的整数,连成一条赚钱最多的路线。若有多条,输出字典序最小的那条路线(编号小的城市靠前的路线优先输出)-descr iption
Traveling Salesman Problem
There are a variety of goods on the market, short-term trading TSP Shrek do make the difference. He bought a piece of merchandise the city, arriving at a neighboring city to sell. If this is a profitable business, then he would not just leave. With their years of experience and his companions, he was well aware of the difference between n cities on the map. There may be a variety of goods between the two cities can make the difference, when Shrek had the biggest profit reselling a commodity.
Now you help Shrek planning a route, so that he can earn the most money.
enter
The first line of two integers n, m. He expressed n cities, numbered 1 ~ n
Then there are m rows, each row of three integers a, b, price, expressed a city to city b can make the difference price.
Export
Several Tab separated integers, and even into a most profitable routes. If multiple output lexicographically smallest that route (a small number of priority urban
Traveling Salesman Problem
市场上有很多种商品,旅行商Shrek做短期买卖赚取差价。他从一个城市购买一件商品,到达下一个相邻的城市就卖掉。如果这一次买卖无利可图,那么他就不会这么走。凭着自己和同伴多年的经验,他已经对地图上n个城市之间的差价了如指掌。两城市间可能有多种商品可赚取差价,此时Shrek只好倒卖利润最大的一件商品。
现在请你帮Shrek规划一条路线,使他能赚最多的钱。
输入
第一行两个整数n、m。表示有n个城市,编号1~n
接下来有m行,每行三个整数a、b、price,表示从城市a到城市b可赚取差价price。
输出
若干Tab分隔的整数,连成一条赚钱最多的路线。若有多条,输出字典序最小的那条路线(编号小的城市靠前的路线优先输出)-descr iption
Traveling Salesman Problem
There are a variety of goods on the market, short-term trading TSP Shrek do make the difference. He bought a piece of merchandise the city, arriving at a neighboring city to sell. If this is a profitable business, then he would not just leave. With their years of experience and his companions, he was well aware of the difference between n cities on the map. There may be a variety of goods between the two cities can make the difference, when Shrek had the biggest profit reselling a commodity.
Now you help Shrek planning a route, so that he can earn the most money.
enter
The first line of two integers n, m. He expressed n cities, numbered 1 ~ n
Then there are m rows, each row of three integers a, b, price, expressed a city to city b can make the difference price.
Export
Several Tab separated integers, and even into a most profitable routes. If multiple output lexicographically smallest that route (a small number of priority urban
(系统自动生成,下载前可以参看下载内容)
下载文件列表
TSP.cpp