题意:

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

【HDOJ6343】Graph Theory Homework(贪心)的更多相关文章

  1. 2018 Multi-University Training Contest 4 Problem L. Graph Theory Homework 【YY】

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6343 Problem L. Graph Theory Homework Time Limit: 2000 ...

  2. HDU 6343 - Problem L. Graph Theory Homework - [(伪装成图论题的)简单数学题]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6343 Time Limit: 2000/1000 MS (Java/Others) Memory Li ...

  3. HDU 6343.Problem L. Graph Theory Homework-数学 (2018 Multi-University Training Contest 4 1012)

    6343.Problem L. Graph Theory Homework 官方题解: 一篇写的很好的博客: HDU 6343 - Problem L. Graph Theory Homework - ...

  4. Introduction to graph theory 图论/脑网络基础

    Source: Connected Brain Figure above: Bullmore E, Sporns O. Complex brain networks: graph theoretica ...

  5. The Beginning of the Graph Theory

    The Beginning of the Graph Theory 是的,这不是一道题.最近数论刷的实在是太多了,我要开始我的图论与树的假期生活了. 祝愿我吧??!ShuraK...... poj18 ...

  6. Codeforces 1109D Sasha and Interesting Fact from Graph Theory (看题解) 组合数学

    Sasha and Interesting Fact from Graph Theory n 个 点形成 m 个有标号森林的方案数为 F(n, m) = m * n ^ {n - 1 - m} 然后就 ...

  7. CF1109D Sasha and Interesting Fact from Graph Theory

    CF1109D Sasha and Interesting Fact from Graph Theory 这个 \(D\) 题比赛切掉的人基本上是 \(C\) 题的 \(5,6\) 倍...果然数学计 ...

  8. HDU6029 Graph Theory 2017-05-07 19:04 40人阅读 评论(0) 收藏

    Graph Theory                                                                 Time Limit: 2000/1000 M ...

  9. Codeforces 1109D. Sasha and Interesting Fact from Graph Theory

    Codeforces 1109D. Sasha and Interesting Fact from Graph Theory 解题思路: 这题我根本不会做,是周指导带飞我. 首先对于当前已经有 \(m ...

随机推荐

  1. AJPFX谈JAVA新手问题之异常处理使用不当

    ★空的 catch 语句块 犯这种错误的人比较少,一般发生在刚学会 Java 或者刚参加工作不久的人身上. 所谓“空 catch 语句块”就是在 catch 语句块中没有对异常作任何处理(比如记错误日 ...

  2. BaseAtapter

    本文用于实现一个通用的BaseAdapter类,统一产品的Adapter类,作为一个工具类,减少重复性工作,增加开发效率. 序 我们在开发项目的过程中,经常会用到ListView.GridView这一 ...

  3. https为数据传输保驾护航

    为什么要使用https 谷歌官网已宣布,今年7月起,Chrome浏览器的地址栏将把所有HTTP标示为不安全网站. 在客户端与服务器数据传输过程中,http协议传输是不安全的,一般情况下,http协议的 ...

  4. xcode6的项目中虚拟键盘无法弹出

    这是因为Xcode6中的模拟器键盘设置跟之前的版本不一样了.之前版本是模拟器的键盘和电脑的键盘都可以使用,但是Xcode6的模拟器键盘只能使用一种,即要么是模拟器键盘,要么是电脑键盘.快捷键切换键盘类 ...

  5. c# sqlserver连接字符串

    odbc: string cnnstring = @"Driver={SQL Server Native Client 11.0};Initial Catalog = sxquadb;ser ...

  6. ie 导出不行,不兼容问题,或只出现后缀文件无法识别

    // 下载模板 @RequestMapping("/download") @ResponseBody public ResponseEntity<byte[]> dow ...

  7. pip和pip3安装、升级、版本查看及遇到的问题

    pip的安装 问题一 sudo apt-get install python-pip #安装pip sudo pip install --upgrade pip -i http://mirrors.a ...

  8. vue 组件内 directives指令的调用方式 <base-table v-auto-height:tableHeight="{vm:this, diffHeight:ahTable.diffHeight}"

    vue 组件内 directives指令的调用方式 <base-table v-auto-height:tableHeight="{vm:this, diffHeight:ahTabl ...

  9. OpenCV2:第四章 导出图像

    一.简介 一般我们用OpenCV来处理图像数据的时候,OpenCV已经把图像数据包装成一个图像数据类,我们只需要对类成员的像素值进行修改就行了. 但是在Windows开发的WinSDK/MFC中,对图 ...

  10. java 数据库(二)

    1.SQL概述 1.什么是SQL(了解): 结构化查询语言,是一种功能齐全的数据库语言.在使用它时,只需要发出“做什么”的命令,“怎么做”是不用使用者考虑的 SQL被美国国家标准局(ANSI)确定为关 ...