| Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|
| 72692 | sh25_zhuwy | 计算分数加减表达式的值 | C++ | Accepted | 0 MS | 252 KB | 332 | 2025-11-02 13:51:41 |
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; double p[n],q[n]; for(int i=0;i<n;i++) { p[i]=i+1; if(i%2==0) { q[i]=1.0; } else { q[i]=-1.0; } } double w=0.00; for(int i=0;i<n;i++) { w=w+q[i]/p[i]; } cout<<fixed<<setprecision(4)<<w; return 0; }