【HDOJ6343】Graph Theory Homework(贪心)
题意:
给定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(贪心)的更多相关文章
- 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 ...
- 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 ...
- 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 - ...
- Introduction to graph theory 图论/脑网络基础
Source: Connected Brain Figure above: Bullmore E, Sporns O. Complex brain networks: graph theoretica ...
- The Beginning of the Graph Theory
The Beginning of the Graph Theory 是的,这不是一道题.最近数论刷的实在是太多了,我要开始我的图论与树的假期生活了. 祝愿我吧??!ShuraK...... poj18 ...
- 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} 然后就 ...
- CF1109D Sasha and Interesting Fact from Graph Theory
CF1109D Sasha and Interesting Fact from Graph Theory 这个 \(D\) 题比赛切掉的人基本上是 \(C\) 题的 \(5,6\) 倍...果然数学计 ...
- HDU6029 Graph Theory 2017-05-07 19:04 40人阅读 评论(0) 收藏
Graph Theory Time Limit: 2000/1000 M ...
- Codeforces 1109D. Sasha and Interesting Fact from Graph Theory
Codeforces 1109D. Sasha and Interesting Fact from Graph Theory 解题思路: 这题我根本不会做,是周指导带飞我. 首先对于当前已经有 \(m ...
随机推荐
- laravel如何查找门脸及注入类方法
门脸模式 通过 config/app.php 查看别名对应类名 Illuminate\Support\Facades\Log ,查看 LoggerInterface 类文件,得:命名空间+接口名 Ps ...
- Qt获取本机IP地址
Qt获取本机IP地址: Qt版本:4.8.6 #include <QtNetwork/QNetworkInterface.h> QString ipAddr; QList<QHost ...
- vijos 1053 Easy sssp
描述 输入数据给出一个有N(2 <= N <= 1,000)个节点,M(M <= 100,000)条边的带权有向图. 要求你写一个程序, 判断这个有向图中是否存在负权回路. 如果从一 ...
- 获取Java接口的所有实现类
获取Java接口的所有实现类 前言:想看基于spring 的最简单实现方法,请直接看 第七步. 本文价值在于 包扫描的原理探究和实现 一.背景 项目开发中,使用Netty做服务端,保持长连接与客户端( ...
- 【vc】高精度时间函数的使用
方法一: 函数定义如下: int UsSleep(int us);//返回实际的微秒延时时间 代码实现如下: //参数一表示 需要等待的时间 微秒为单位 int UsSleep(int us) { / ...
- Bootstrap 3 Glyphicons are not working
Bootstrap 3 Glyphicons are not working 解答1 Note to readers: be sure to read @user2261073's comment a ...
- 在window下搭建即时即用的hyperledger fabric 的环境
有版本号的严格按要求,遇到不少坑 1)安装git 版本无要求 2)安装go 1.9 配置环境变量 3)安装Vagrant 1.9.4 4)安装VirtualBox 5.1.28 5)在go ...
- merge dict key
#!/usr/local/python # -*- coding:utf-8 -*-user_dict = {'python': 23, 'Python': 51, '机器':10, 'PYTHON' ...
- 在ios中使用FMDB
SQLite (http://www.sqlite.org/docs.html) 是一个轻量级的关系数据库.iOS SDK很早就支持了SQLite,在使用时,只需要加入 libsqlite3.dyli ...
- 717. 1-bit and 2-bit Characters@python
We have two special characters. The first character can be represented by one bit 0. The second char ...