taotao09 @ 2022-07-19 18:53:12
#include<iostream>
using namespace std;
int main()
{
int k,n=0;
float sn=0;
cin>>k;
while (sn<=k){
n++;
sn+=(float)1/n;
}
cout<<n;
return 0;
}
求各位大佬看看为什么才60分
by kevin3 @ 2022-07-20 11:35:38
@taotao09 float不行,要用double
by andyayy @ 2022-08-03 07:51:51
double!!!!
#include<bits/stdc++.h>
using namespace std;
int main(){
double n,sum=0,s=2;
cin>>n;
while(n>0){
n-=s;
s*=0.98;
sum++;
}
cout<<sum;
return 0;
}
by gfoi_lyl @ 2022-08-06 16:01:51
using namespace std; int main(){ double a,b=0,i=1; cin>>a; for(;b<=a;i++)b+=1/i; cout<<i-1; }
by 004Tingting @ 2022-08-20 01:01:46
@andyayy 请问为什么要用double啊
by andyayy @ 2022-08-20 20:40:24
@004Tingting 布吉岛啊,反正用就对了
by Uesugi__Erii @ 2022-08-24 15:58:15
@004Tingting 因为是双精度,保留小数点后第2位