为什么我这个代码提交上去了,提示Memory Limit Exceeded(MLE)
#include<bits/stdc++.h>
using namespace std;
struct position
{
int x1, x2, x3, y1, y2, y3;
} pos;
int distance(int x1, int y1, int x2, int y2)
{
return sqrt(pow(abs((x2 - x1)), 2) + pow(abs((y2 - y1)), 2));
}
int main()
{
cin >> pos.x1 >> pos.y1 >> pos.x2 >> pos.y2 >> pos.x3 >> pos.y3;
double ans = 0;
ans = distance(pos.x1, pos.y1, pos.x2, pos.y2) + distance(pos.x2, pos.y2, pos.x3, pos.y3) + distance(pos.x3, pos.y3, pos.x1, pos.y1);
printf ("%.2lf", ans);
return 0;
}
题目来自于洛谷
题目网址:https://www.luogu.com.cn/problem/P5735