为什么开O2优化就TLE,关了就AC

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

zyl_0091 @ 2024-09-28 11:59:42

#include <bits/stdc++.h>
using namespace std;
int dis(){
    float a,b,c,d,e,f;
    float m,n,p,q;
    cin>>a>>b;
    cin>>c>>d;
    cin>>e>>f;
    m = sqrt((e - a) * (e - a) + (f - b) * (f - b));
    n = sqrt((c - a) * (c - a) + (d - b) * (d - b));
    p = sqrt((e - c) * (e - c) + (f - d) * (f - d));
    q = float(m + n + p);
    printf("%.2f", q);
}
int main(){
    dis();
    return 0;
}

by cly312 @ 2024-09-28 12:04:07

因为dis没有返回


by cly312 @ 2024-09-28 12:04:52

@zyl_0091 改成void dis()即可,求关注


|