舒适的路线
来源:互联网 发布:梦里花落知多少txt下载 编辑:程序博客网 时间:2024/06/10 08:49
http://wikioi.com/problem/1001/
// File Name: wiki1001.cpp// Author: bo_jwolf// Created Time: 2013年08月18日 星期日 08时40分44秒#include<vector>#include<list>#include<map>#include<set>#include<deque>#include<stack>#include<bitset>#include<algorithm>#include<functional>#include<numeric>#include<utility>#include<sstream>#include<iostream>#include<iomanip>#include<cstdio>#include<cmath>#include<cstdlib>#include<cstring>#include<ctime>#define INF 0xffffffusing namespace std;const int maxn = 5005 ;struct node{int x , y , v ;bool operator < ( const node a ) const {return v < a.v ;}}edge[ maxn ] ;int n , m , s ,t , k , Max , Min ;int fa[ maxn ] ;int find( int x ){return fa[ x ] = fa[ x ] == x ? x : find( fa[ x ] ) ;}int gcd( int a , int b ){return b == 0 ? a : gcd( b , a % b ) ;}int main(){double ans = INF ;cin >> n >> m ;{for( int i = 1 ; i <= m ; ++ i ){cin >> edge[ i ]. x >> edge[ i ].y >> edge[ i ].v ;}cin >> s >> t ;sort( edge + 1 , edge + 1 + m ) ;for( int i = 1 ; i <= m ; ++i ){for( int j = 0 ; j <= n ; ++j )fa[ j ] = j ;for( int j = i ; j <= m ; ++j ){if( find( edge[ j ].x ) != find( edge[ j ].y) )fa[ fa[ edge[ j ].x ] ] = fa[ edge[ j ].y ] ;if( find( s ) == find( t ) ){if( edge[ j ].v / 1.0 / edge[ i ].v < ans ) {Max = edge[ j ].v ;Min = edge[ i ].v ;ans = edge[ j ].v / 1.0 / edge[ i ].v ;}break ;}}}if( ans == INF )cout << "IMPOSSIBLE" << endl ;else{int temp = gcd( Max , Min ) ;Max /= temp ;Min /= temp ;cout << Max ;if( Min != 1 )cout << "/" << Min ;cout << endl ;}}return 0;}
- 舒适的路线
- 最舒适的路线
- codevs1001 舒适的路线
- wikioi1001 舒适的路线
- 1001 舒适的路线
- codevs1001 舒适的路线
- 舒适的路线
- wikioi 1001 舒适的路线
- nyoj-最舒适的路线
- wikioi 1001 舒适的路线
- 舒适的路线 2006年
- Codevs 1001 舒适的路线
- codevs 1001 舒适的路线
- Codevs 1001 舒适的路线
- codevs 1001 舒适的路线
- 【codevs 1001】舒适的路线
- codevs 1001 舒适的路线
- 【codevs 1001】舒适的路线
- [DP]Tower
- 学生信息管理系统——配置windows防火墙允许访问SQL Server 2008服务器
- (转)opencv--直方图&最大熵分割
- 封装,继承,多态的作用
- uva 11892 ENimEN 简单博弈
- 舒适的路线
- 二维条码防伪技术原理及应用简介
- NYOJ 414题 Sky number
- opencv读取自定义bmp灰度图片
- OOD 启示录,C++内存泄漏
- 如何高效使用SQLite .net (C#)
- 8#15 - 多校8
- 可伸缩性最佳实践:来自eBay的经验
- poj2823(单调队列)