long_long @ 2019-11-03 16:48:53
#include <iostream>
#include <cstdio>
using namespace std;
int n, ans=1;
int main(){
cin>>n;
for(int i=0; i<n; i++){
ans+=1/i;
}
cout>>ans;
return 0;
}
by zjjws @ 2019-11-03 16:50:51
by long_long @ 2019-11-03 16:51:59
@zjjws 谢谢大佬,AC了
by long_long @ 2019-11-03 16:53:33
@zjjws 大佬,i<n怎么改?
by zjjws @ 2019-11-03 16:56:33
@long_long ?
by zjjws @ 2019-11-03 16:58:12
@long_long
by zjjws @ 2019-11-03 16:58:51
@long_long
by zjjws @ 2019-11-03 17:00:11
by zjjws @ 2019-11-03 17:04:05
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL rin()
{
LL s=0;
bool bj=0;
char c=getchar();
while((c>'9'||c<'0')&&c!='-')c=getchar();
if(c=='-')bj=1,c=getchar();
while(c>='0'&&c<='9')s=s*10+c-'0',c=getchar();
if(bj)return -s;
return s;
}
int main()
{
int i,j;
int k=rin();
double s=1;
for(i=2;s<=k;i++)
{
double z=1;
z/=i;
s+=z;
}
i--;
printf("%d",i);
return 0;
}
by 编程萌新or大神 @ 2019-11-09 13:42:27
不能从0