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 }

 

 



posted @ 2019-08-05 10:19  YukiRinLL  阅读(104)  评论(0编辑  收藏  举报