题目描述
If you have solved the small water problem,let's see this big one.If you don't,I suggest you ignore this problem!
Also give you a positive integer n.
Function F_x satisfies:
F_0 = cos{n}
F_x = cosF_{x-1} (x>0)
Calculate F_n.
输入格式
The input contains no more than 20 test cases.
For each test case,the only line consists of one integer n.
0<=n<=10^30.
输出格式
For each given n,print the answer in a single line.The result should be rounded to six decimal places.
输入样例
0
1
2
输出样例
1.000000
0.857553
0.610065
此题与H题类似,不同的是n的值非常大,但是捏, n>35时,F_(n)为定值0.739085,
接下来就很简单啦!
完整代码如下:
#include<bits/stdc++.h>
using namespace std;
double F_(double x,double n)
{
if(x==0)
return cos(n);
else if(n>40)
return 0.739085;
else
return cos(F_(x-1,n));
}
int main()
{
double x;
while(cin>>x)
printf("%lf\n",F_(x,x));
}