Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
31313 | lnx | 求分数序列和 | C++ | Accepted | 0 MS | 252 KB | 289 | 2023-11-18 13:08:15 |
#include<iostream> #include<iomanip> using namespace std; int main() { int n; cin>>n; int p[n],q[n]; p[1]=1; q[1]=2; double s=2; for(int i=2;i<=n;i++) { p[i]=q[i-1]; q[i]=p[i-1]+q[i-1]; s+=(q[i]*1.0/p[i]); } cout<<fixed<<setprecision(4)<<s; return 0; }