http://acm.hdu.edu.cn/showproblem.php?pid=1690

坑爹的题,必须用__int64 %I64d(以前没用过)

因为这题的数据特别大,所以用-1

 #include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
using namespace std;
__int64 map[][];
__int64 L[],C[];
__int64 a[];
int n,m;
void Floy()
{
for(int k=;k<=n;k++)
{
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{
if(map[i][k]==-||map[k][j]==-)//
continue;
if(map[i][j]==-||map[i][k]+map[k][j]<map[i][j])//执行这步,说明map[i][k],map[k][j]都存在
map[i][j]=map[i][k]+map[k][j];
}
}
}
} int main()
{
int T;
int K=;
scanf("%d",&T);
while(T--)
{
K++;
for(int i=;i<=;i++)
scanf("%I64d",&L[i]);
for(int i=;i<=;i++)
scanf("%I64d",&C[i]);
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)
{
scanf("%I64d",&a[i]);
}
__int64 t;
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{ t=abs(a[j]-a[i]);//这里自己出错了,输入时坐标是不会按顺序输入的 if(t==)
{
map[i][j]=;
map[j][i]=;
}
else if(t>&&t<=L[])
{
map[i][j]=C[];
map[j][i]=C[]; }
else if(t>L[]&&t<=L[])
{
map[i][j]=C[];
map[j][i]=C[]; }
else if(t>L[]&&t<=L[])
{ map[i][j]=C[];
map[j][i]=C[]; }
else if(t>L[]&&t<=L[])
{ map[i][j]=C[];
map[j][i]=C[]; }
else
{
map[i][j]=-;
map[j][i]=-;
} }
}
Floy();
printf("Case %d:\n",K);
int yy,uu;
for(int i=;i<m;i++)
{
scanf("%d%d",&yy,&uu);
if(map[yy][uu]==-)
printf("Station %d and station %d are not attainable.\n",yy,uu);
else
{
printf("The minimum cost between station %d and station %d is %I64d.\n",yy,uu,map[yy][uu]); }
} }
return ;
}

Bus System(Flody)的更多相关文章

  1. HDU ACM 1690 Bus System (SPFA)

    Bus System Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  2. hdu1690 Bus System(最短路 Dijkstra)

    Problem Description Because of the huge population of China, public transportation is very important ...

  3. hdu 1690 Bus System (有点恶心)

    Problem Description Because of the huge population of China, public transportation is very important ...

  4. 关于system(”pause“);的作用和意义

    注意:不要再return 的语句之后加,那样就执行不到了. system() 是调用系统命令:pause 暂停命令: 如果加有  system(”pause“): 这样在运行到此处时,会显示“Pres ...

  5. hdu1690 Bus System (dijkstra)

    Problem Description Because of the huge population of China, public transportation is very important ...

  6. 关于system()的一些用法

    C语库函数 函数名: system  功  能: 发出一个DOS命令  用  法: int system(char *command);  它包含头文件<stdlib.h>  system ...

  7. system()函数

    windows下system () 函数详解 windows操作系统下system () 函数详解(主要是在C语言中的应用) 函数名: system   功 能: 发出一个DOS命令   用 法: i ...

  8. hdu 1690 Bus System (最短路径)

    Bus System Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  9. hdu 1690 Bus System(Dijkstra最短路)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1690 Bus System Time Limit: 2000/1000 MS (Java/Others ...

随机推荐

  1. 【转载】Yui.Compressor高性能ASP.NET开发:自动压缩CSS、JS

    在开发中编写的js.css发布的时候,往往需要进行压缩,以减少文件大小,减轻服务器的负担.这就得每次发版本的时候,对js.js进行压缩,然后再发布.有没有什么办法,让代码到了服务器上边,它自己进行压缩 ...

  2. 【2014年12月6日】HR交流会

    今天的交流会感觉还是不错,体会到了一些东西,把它记下来. 想到什么写什么,可能没什么条理. 1.先选行业,再选职业,再选公司 根据自己的兴趣以及个人特长,能力等方面,需要定一个大概的方向,然后根据方向 ...

  3. SQL Server 优化总结

    1.作为过滤条件字段的数据表,在拼接语句尽量优先拼接,以提升查询效率

  4. 【Spring Boot&&Spring Cloud系列】Spring Boot项目集成Swagger UI

    前言 Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 Web 服务.总体目标是使客户端和文件系统作为服务器以同样的速度来更新.文件的方法,参数和模型紧密集 ...

  5. 动力学仿真引擎ODE的学习笔记,C#演示(一)

    ®版权声明:本文为博主原创文章,未经博主允许不得转载. 一.ODE介绍与平台搭建. 接触到动力学仿真引擎, 是因为笔者的一款PLC仿真软件需要3D仿真.我需要达到的效果是,以3D方式构建出工控行业中常 ...

  6. Ubuntu Eclipse配置Python开发环境

    一 在Eclipse中安装pydev插件 启动Eclipse, 点击Help->Install New Software... 在弹出的对话框中,点Add 按钮. Name中填:Pydev Lo ...

  7. ubuntu14.04_install_gitlab_platform

    /** author: lihaibo URL:http://www.cnblogs.com/horizonli/p/5321770.html */ 下面是干货 [第一部分 安装] 环境:ubuntu ...

  8. gcc6.3的安装

    author:headsen  chen date: 2018-10-12  15:11:35 1,环境:centos7.3 ,64位,内核 3.10 2,安装过程 #!/bin/bash yum i ...

  9. Eui中eui.Image的source和texture属性赋值导致的获取高宽为0问题

    引擎5.2.5版本 一个eui.Image,给source和texture赋值,获取高宽会不同 = = ! let img:eui.Image = new eui.Image(); img.sourc ...

  10. 23种设计模式之模板方法(Template Method)

    模板方法模式是一种类的行为型模式,用于定义一个操作中算法的骨架,而将一些步骤延迟到子类中.模板方法模式使得子类可以不改变一个算法的结构即可重定义该算法的某些特定步骤,其缺点是对于不同的实现,都需要定义 ...