zoukankan      html  css  js  c++  java
  • poj2253 Frogger

    Frogger
    题意:
    1.无论你跳多远跳多少次 这些都不限制你 也无论点有多远 都能跳到
    2.每条从点1到点2的路径中,跳的最大那一步为这条路径的代价
    3.求出最小代价的路径。
    ps:我看了N就没看明白,最后看了discuss后才明白。
    View Code
     1 #include<iostream>
     2 #include<string>
     3 #include<queue>
     4 #include<map>
     5 #include<cmath>
     6 #include<stack>
     7 #include<algorithm>
     8 using namespace std;
     9 const int N=222;
    10 int coord[N][2];
    11 int str[N][N];
    12 #define dis(j,i) ((coord[i][0]-coord[j][0])*(coord[i][0]-coord[j][0])+(coord[i][1]-coord[j][1])*(coord[i][1]-coord[j][1]))
    13 
    14 int main()
    15 {
    16     int n,i,j,k,tmp,Case=0;
    17 
    18     while(scanf("%d",&n),n){
    19         for(i=0;i<n;i++){
    20             scanf("%d%d",&coord[i][0],&coord[i][1]);
    21             for(int j=0;j<i;j++){
    22                 str[i][j]=str[j][i]=dis(j,i);
    23             }
    24         }
    25 
    26             for(k=0;k<n;k++)
    27             for(i=0;i<n;i++){
    28                 if(i==k)continue;
    29                 for(j=0;j<n;j++){
    30                     if(j==i || j==k)continue;
    31                     
    32                     if(str[i][k]>str[k][j])tmp=str[i][k];
    33                     else tmp=str[k][j];
    34                     
    35                     if(str[i][j]>tmp){
    36                         str[i][j]=tmp;
    37                     }
    38                 }
    39             }
    40         
    41         if(Case)puts("");
    42         printf("Scenario #%d\n",++Case);
    43         printf("Frog Distance = %.3f\n",sqrt(str[0][1]*1.0));
    44     }
    45     return 0;
    46 }
  • 相关阅读:
    WINDOWS REDIS 修改requirepass 不生效;
    解读JavaScript原型链
    禁止浏览器自动填写用户名密码
    Vue购物车实例
    scrollTop的兼容性
    jQuery架构(源码)分析
    web前端优化整理(转)
    前端模块化:RequireJS(转)
    前端构建之gulp与常用插件(转载)
    PS快捷键
  • 原文地址:https://www.cnblogs.com/tiankonguse/p/2615457.html
Copyright © 2011-2022 走看看