P1035 题解
getchar_unlocked · · 题解
题目传送门
思路
用一个 while 循环进行模拟,循环条件为
注意事项
AC CODE
#include<bits/stdc++.h>
using namespace std;
int read(){int x=0;char f=1,ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();return x*f;}
int main(){
int k=read(),cnt=0;
double n=0;
while(n<=k){
++cnt;
n+=1.0/cnt;
}
printf("%d\n",cnt);
return 0;
}