L - Problem L. Graph Theory Homework HDU - 6343

 

Sample Input

1
3
1 3 5

Sample Output

2

题意
带权值的N个点,每两点之间边长度

求1~N最短路


思路

  

  直接算首尾两个点
  所以其实不算图论题
code
 1 #include <bits/stdc++.h>
 2 #include <iostream>
 3 #include <cstring>
 4 #include <stack>
 5 #include <cstdlib>
 6 #include <queue>
 7 #include <cmath>
 8 #include <cstdio>
 9 #include <algorithm>
10 #include <string>
11 #include <vector>
12 #include <list>
13 #include <iterator>
14 #include <set>
15 #include <map>
16 #include <utility>
17 #include <iomanip>
18 #include <ctime>
19 #include <sstream>
20 #include <bitset>
21 #include <deque>
22 #include <limits>
23 #include <numeric>
24 #include <functional>
25 
26 #define gc getchar()
27 #define mem(a) memset(a,0,sizeof(a))
28 #define mod 1000000007
29 #define sort(a,n,int) sort(a,a+n,less<int>())
30 #define fread() freopen("in.in","r",stdin)
31 #define fwrite() freopen("out.out","w",stdout)
32 using namespace std;
33 
34 typedef long long ll;
35 typedef char ch;
36 typedef double db;
37 
38 const int maxn=1e5+10;
39 //ll a[maxn];
40 int aa[maxn];
41 
42 
43 int gcd(int a,int b){
44     if(a<b)swap(a,b);
45     if(a%b==0)return b;
46     else gcd(b,a%b);
47 }
48 int a[maxn];
49 int main()
50 {
51     int T;
52     int n;
53     cin >> T;
54     while(T--){
55         cin >> n;
56         for(int i = 1;i<=n;i++)
57             cin >> a[i];
58         int res = sqrt(abs(a[n] - a[1]) );
59         cout << res << endl;
60     }
61 }

 

 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YukiRinLL

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值