#include "pch.h"
#include <iostream>
constexpr auto PI = (3.1415926535897932384626433832795);
using namespace std;
//计算离散化后的面积损失
double getMinusArea(double rad,int n)
{
//圆形面积
double cirArea = rad * rad*PI;
//多边形面积
double ang = PI / n;
double rectArea = n * (rad*rad*sin(ang)*cos(ang));
return cirArea - rectArea;
}
int main()
{
int rad = 50;//半径
int minArea = 5;//面积差
//圆形面积
int resNum = 0;
int num = 1;
while (true)
{
double dminArea = getMinusArea(rad, num++);
if (dminArea < minArea)
{
resNum = num;
break;
}
}
cout << "n = " << resNum << endl;
}