Li_mz__ @ 2022-11-11 18:23:41
#include <bits/stdc++.h>
using namespace std;
int main(){
int k;
scanf("%d",&k);
int ans = 0,ann = 0;
int i = 1;
while(ans <= k){
ann += 1 / i;
ans++;
if(ann > k){
break;
}
i++;
}
printf("%d",ans);
return 0;
}
by _zhy @ 2022-11-11 18:30:49
double
by Li_mz__ @ 2022-11-11 18:33:00
@钟浩洋 哦,ans和ann?
by _zhy @ 2022-11-11 18:34:40
ann,i,k
by Li_mz__ @ 2022-11-11 18:36:09
@钟浩洋
int main(){
double k;
scanf("%d",&k);
double ann = 0;
int ans = 0;
double i = 1;
while(ans <= k){
ann += 1 / i;
ans++;
if(ann > k){
break;
}
i++;
}
printf("%d",ans);
return 0;
}
还是WA
by Li_mz__ @ 2022-11-11 18:38:01
@钟浩洋 《scanf("%d",&k);》
《printf("%d",ans);》
by _zhy @ 2022-11-11 18:39:38
int main(){
double k;
scanf("%lf",&k);
double ann = 0;
int ans = 0;
double i = 1;
while(true){
ann += 1 / i;
ans++;
if(ann > k){
break;
}
i++;
}
printf("%d",ans);
return 0;
}
by Li_mz__ @ 2022-11-11 18:50:57
@钟浩洋 A了,谢谢