题意:

给定n个点,每个点有权值a[i],从A走到B的花费是下取整sqrt(a[i]-a[j]),求从1号点走到n号点的最小花费

1<=n,a[i]<=1e5

思路:

 #include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef vector<int> VI;
#define fi first
#define se second
#define MP make_pair const int N=;
int a[N],n,cas;
int read()
{
int v=,f=;
char c=getchar();
while(c<||<c) {if(c=='-') f=-; c=getchar();}
while(<=c&&c<=) v=(v<<)+v+v+c-,c=getchar();
return v*f;
} int main()
{
// freopen("1.in","r",stdin);
//freopen("1.out","w",stdout);
scanf("%d",&cas);
for(int i=;i<=cas;i++)
{
scanf("%d",&n);
for(int j=;j<=n;j++) scanf("%d",&a[j]);
int t=sqrt(abs(a[n]-a[]));
printf("%d\n",t);
}
return ;
}

最新文章

  1. Hadoop的核心组件和生态圈
  2. PHP Warning: PHP Startup: in Unknown on line 0
  3. JAVA学习博客---2015-8
  4. Java:集合for高级循环遍历
  5. Linux 挂载iso,并设置为源
  6. 动态可视化库Vis.js:社交关系谱
  7. window.location.href 和 document.location.href
  8. python3 第二章 - 第一个程序
  9. Zookeeper分布式服务协调组件
  10. 安卓手机USB共享网络给PC上网
  11. mpvue-Vant Weapp踩坑记
  12. 图片懒加载、selenium和PhantomJS
  13. php(curl请求)测试接口案例
  14. Oracle列转行函数LISTAGG()
  15. 关于不执行整个大项目而是执行其中一部分独立文件夹的时候的python运行方法
  16. javascript 面向过程和面向对象
  17. CSS: Position Introduction.
  18. openstack项目【day23】:虚拟化介绍
  19. lua lua_settable
  20. CentOS 安装Sqlite3

热门文章

  1. Git-远程操作
  2. 自定义 TypeHandler
  3. java实现斐波那契的两种方法
  4. UI常用字体定义和继承的实例,ResearchKitCode
  5. apropos命令
  6. 导入Excel表格(二)
  7. Linux之vi(vim)编辑器
  8. linux部署全流程(未完)
  9. 一个Lucene.Net的Demo
  10. RN传参的问题