Score sequence and

Topic link: http://exercise.acmcoder.com/online/online_judge_ques?ques_id=3371&konwledgeId=40

Problem-solving ideas: Just solve it directly.

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 typedef long long LL;
 5 const int MAXN=100005;
 6 const LL MON7 = 1e9+7;
 7 
 8 unsigned long long f[92];
 9 double ans[92];
10 
11 void init()
12 {
13     f[0]=1;
14     f[1]=1;
15     for (int i=2;i<=91;++i) f[i]=f[i-1]+f[i-2];
16     // for (int i=2;i<=91;++i) printf("%llu\n",f[i]);
17     ans[0]=0;
18     for (int i=1;i<=90;++i) ans[i]=ans[i-1]+1.0*f[i+1]/f[i];
19     // for (int i=1;i<=90;++i) printf("%.8f\n",ans[i]);
20 }
21 int main()
22 {
23 #ifndef ONLINE_JUDGE
24     freopen("test.txt","r",stdin);
25 #endif // ONLINE_JUDGE
26     init();
27     int Case;
28     int n;
29     scanf("%d",&Case);
30     while (Case--)
31     {
32         scanf("%d",&n);
33         printf("%.4f\n",ans[n]);
34     }
35     return 0;
36 }

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324738068&siteId=291194637
Recommended