Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
335215 | 李俞家骅 | 【C2-2】 编程求1+1/2+1/3+...+1/n | C++ | 通过 | 100 | 4 MS | 248 KB | 219 | 2025-07-22 10:45:30 |
#include<bits/stdc++.h> using namespace std; int main(){ int n,i; double x=0; cin>>n; i=1; while(i<=n){ x=x+1.0/i; i++; } cout<<fixed<<setprecision(3)<<x<<endl; return 0; }