我服了

P5735 【深基7.例1】距离函数

jywa @ 2024-08-16 11:12:44

为什么我的前四个是AC,最后一个测试端却是WA呢?


by return_second @ 2024-08-16 11:14:18

@jywa Where is your code?


by zhizhenhuyuzhe @ 2024-08-16 11:15:18

#include<bits/stdc++.h>
using namespace std;
    struct k{
        double q,w;//x1,y1;
    };
    struct u{
        double e,r;//x2,y2;
    };
    struct n{
        double t,u;//x3,y3;
    };
    k a;
    u b;
    n c;    
int main(){
    cin>>a.q>>a.w>>b.e>>b.r>>c.t>>c.u;
    double f,g,h;
    f=sqrt((b.e-a.q)*(b.e-a.q)+(b.r-a.w)*(b.r-a.w));
    g=sqrt((c.t-a.q)*(c.t-a.q)+(c.u-a.w)*(c.u-a.w));
    h=sqrt((c.t-b.e)*(c.t-b.e)+(c.u-b.r)*(c.u-b.r));
    cout<<fixed<<setprecision(2)<<(f+g+h);     
    return 0;
}

by Emil_ @ 2024-08-16 11:22:05

@jywa

#include <bits/stdc++.h> 
using namespace std;
double dis(double x1,double y1,double x2,double y2){
    return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}
int main(){
    double x1,y1,x2,y2,x3,y3;
    cin>>x1>>y1>>x2>>y2>>x3>>y3;
    printf("%.2lf",dis(x1,y1,x2,y2)+dis(x1,y1,x3,y3)+dis(x3,y3,x2,y2));
    return 0;
}

求关,谢谢


by jywa @ 2024-08-17 18:00:27

谢谢啦,各位大佬,可以加一下我的龙天工作室,地址https://www.luogu.com.cn/team/86356


by jywa @ 2024-08-17 18:01:19

@Emil_ 谢谢啦,各位大佬,可以加一下我的龙天工作室,地址https://www.luogu.com.cn/team/86356


by jywa @ 2024-08-17 18:01:31

@zhizhenhuyuzhe 谢谢啦,各位大佬,可以加一下我的龙天工作室,地址https://www.luogu.com.cn/team/86356


by jywa @ 2024-08-17 18:02:23

@return_second I don't know,but you can enjoy our club,ID: https://www.luogu.com.cn/team/86356


by Emil_ @ 2024-08-17 19:06:43

@jywa ok


by abc20131113 @ 2024-08-23 10:57:36

@jywa 你是不是中国的...


|