• L


    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 }


    作者:YukiRinLL

    出处:YukiRinLL的博客--https://www.cnblogs.com/SutsuharaYuki/

    您的支持是对博主最大的鼓励,感谢您的认真阅读。

    本文版权归作者所有,欢迎转载,但请保留该声明。

  • 相关阅读:
    zap日志库
    Go Logger库基本使用
    golang中的MySQL增删改查
    golang链接mysql
    文件上傳
    參數綁定:
    gin獲取path參數
    gin獲取form提交的表單數據
    獲取query string
    返回json
  • 原文地址:https://www.cnblogs.com/SutsuharaYuki/p/11301423.html
Copyright © 2020-2023  润新知