题解:P2433 【深基1-2】小学数学 N 合一
GoldenSTEVE7
·
·
题解
这是一篇整活题解
众所周知
\lim_{x\rightarrow0} \frac{\sin x}{x} = 1
我们把 $x$ 取小亿点点,精度可能是过得去的。
这样,把所有的常数全部换成一个极限,那也过得去嘛!
AC 代码:
```cpp
#include<iostream>
#include<cmath>
#define double long double
using namespace std;
double Sin(double x) {
double ret = x, a = x, p = x * x, cur = 1;
for (int i = 1; i <= 100; i++) {
cur *= (2 * i) * (2 * i + 1); a *= p / cur;
if (i % 2 == 0) ret += a;
else ret -= a;
}
return ret;
}
int main()
{
double x = 0.0000001;
double q = Sin(x) / x;
int T;
cin >> T;
if (T == 1)
{
cout << "I love Luogu!";
}
else if (T == 2)
{
cout << 6*q << " " << 4*q;
}
else if (T == 3)
{
cout << 3*q << endl << 12*q << endl <<2*q;
}
else if (T == 4)
{
cout << q * 500 / 3;
}
else if (T == 5)
{
cout << ( 260 + 220 )*q / ( 12 + 20 )*q;
}
else if (T == 6)
{
cout << sqrt(pow(6 , 2) + pow (9 , 2));
}
else if (T == 7)
{
cout << 110*q << endl << 90*q << endl << 0;
}
else if (T == 8)
{
cout <<2*3.141593*5<<endl<<3.141593*5*5<<endl<<4.0/3*3.141593*5*5*5;
}
else if (T == 9)
{
cout <<(((q+q)*2+q)*2+q)*2;
}
else if (T == 10)
{
cout << 9*q;
}
else if (T == 11)
{
cout << 33.3333;
}
else if (T == 12)
{
cout << 13*q << endl << "R";
}
else if (T == 13)
{
cout << 16*q;
}
else if (T == 14)
{
cout << 50*q;
}
return 0;
}
```