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. CSS - 移动端 常见小bug整理与解决方法总结【更新中】

    常见问题总结与整理系列~ 1. border一像素在手机上看着有点粗的问题: 原理是因为:1px在手机上是使用2dp进行渲染的.换成 border: 0.5像素?是不行的! 解决方法: 把border ...

  2. CSS改变插入光标颜色caret-color简介及其它变色方法(转)

    一.CSS改变输入框光标颜色的原生属性caret-color CSS caret-color属性可以改变输入框插入光标的颜色,同时又不改变输入框里面的内容的颜色. 例如: input { color: ...

  3. 重建索引:ALTER INDEX..REBUILD ONLINE vs ALTER INDEX..REBUILD

    什么时候需要重建索引 1. 删除的空间没有重用,导致 索引出现碎片 2. 删除大量的表数据后,空间没有重用,导致 索引"虚高" 3.索引的 clustering_facto 和表不 ...

  4. mysql索引覆盖之innodb和myisam效率问题

    问题: create table A (    id varchar(64) primary key,    ver int,    ... ) 我的表有几个很长的字段varchar(3000) 在i ...

  5. 画一条0.5px的边

    1.scale方法 { height: 1px; transform: scaleY(0.5); transform-origin: 50% 100%; // 要指定origin值, 要不然会模糊 c ...

  6. Artech的MVC4框架学习——第二章URL路由

    总结:HttpModule 和HttpHandler是Asp.net管道的两个重要组件.请求最终处理通过HttpHandler完成.MVC就是通过名为MvcHandler自定义HttpHandler现 ...

  7. jmeter中Implementation中几个选项的区别

    在jmeter发送http请求时,Implementation下拉框中有几个选项,如下: 那到底有什么区别呢?发送http请求改用哪种方法呢.百度后查之,没答案.我们还是看官方文档吧.官方文档解释如下 ...

  8. 常见的几个js疑难点,match,charAt,charCodeAt,map,search

            JavaScript match() 方法 定义和用法 match() 方法可在字符串内检索指定的值,或找到一个或多个正则表达式的匹配. 该方法类似 indexOf() 和 lastI ...

  9. RSA加密工具类(非对称加密算法)

    import com.jfinal.log.Log;import org.apache.commons.codec.binary.Base64; import javax.crypto.Cipher; ...

  10. [励志英语片段]practicing deliberately

    最近看到一篇鸡汤文,觉得措词造句皆为吾辈所能接受,以后可以用作写作或口语素材~ 文章中心思想:同样是训练100小时,结果可以大不一样~所以不要用时间来欺骗自己. Consider the activi ...