HDU6343 Problem L. Graph Theory Homework

原题:http://acm.hdu.edu.cn/showproblem.php?pid=6343

分析:签到题,直接拿第一个数和最后一个数进行运算即可,记得向下取整。

#include<bits/stdc++.h>
using namespace std;
const int maxn = 100000+100;
int a[maxn];

int t, n, m;



int main(){
    scanf("%d", &t);
    while(t--){
        scanf("%d", &n);
        for(int i=1; i<=n; i++) scanf("%d", &a[i]);
        int temp = abs(a[1] - a[n]);
        double ans = sqrt(temp);
        cout<<floor(ans)<<endl;
        
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/m0_37611893/article/details/81349059
今日推荐