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 ;
}

最新文章

  1. 天气预报API开发
  2. mysql 安装以及运行
  3. AjaxControlToolKit--TabContainer控件的介绍
  4. 【Spark】---- Spark 硬件配置
  5. 二模 (3) day2
  6. php_2
  7. ural 1998 The old Padawan
  8. Android实例-闪光灯的控制(XE8+小米2)
  9. css制作导航栏的上下三角
  10. ping-tool
  11. EF6.0执行sql存储过程案例
  12. win10 uwp 无法附加到CoreCLR
  13. EntityFramework优化:第一次启动优化
  14. C#代码中插入X86汇编
  15. ssh: connect to host github.com port 22: Connection timed out
  16. java中常用的进制转换
  17. 笔记react router 4(三)
  18. RAID卡的缓存与磁盘自带的缓存的关系
  19. Python encode() 方法
  20. BZOJ4923 K小值查询(splay)

热门文章

  1. .net webservices 代理类生成命令
  2. 【Spring Boot&amp;&amp;Spring Cloud系列】Spring Boot初识
  3. 【Java基础】System的arraycopy方法拷贝数组
  4. sencha touch + Cordova 3.x下载文件
  5. [原]Openstack之identity server(keystone)
  6. vue生成路由实例, 使用单个vue文件模板生成路由
  7. MFC创建好的对话框如何移植到新程序中
  8. http get请求参数拼接
  9. [LintCode] Invert Binary Tree 翻转二叉树
  10. Python 基础知识(二)