271 条题解
- 
  6啡咖啡咖啡咖啡咖 LV 8 @ 2018-08-18 09:54:34 #include<cstdio> int a,b,c; double ans; int main() { scanf("%d",&a); int i=1; while(ans<=a) { ans+=1.0/i; i++; } printf("%d",i-1); return 0; }
- 
  1@ 2024-06-12 18:44:08还没用过“Vijos”,来水一发题解玩玩 #include<bits/stdc++.h> // 万能头 using namespace std; //标准命名空间 int k,n; //全局变量更推荐 double sn; int main(){ //主函数 ios::sync_with_stdio(0); //关闭同步流以加快输入输出效率 cin.tie(0);cout.tie(0); // 本人亲测:比 printf 快(但不能和 printf 一起用) register int i,j,k; //寄存器变量 cin>>k; //输入 while(sn<=k){//当sn大于等于k时停止循环 n++; //变量n加1,停止时为sn超过k时的次数 sn+=(double)1/n; } cout<<n; //输出sn return 0; //庄严地结束程序 }
- 
  1@ 2023-08-08 13:02:14#include <stdio.h> #include<bits/stdc++.h> int main() { int a=2; double s = 0; int i; int k; scanf("%d",&k); if(k!=1) { for(i = 1; ; i ++) { s+=1.0/i; if(s>=k)break; } printf("%d\n", i); } else printf("%d\n",a); return 0; }
- 
  1@ 2018-08-18 09:52:33#include<iostream> using namespace std; int main() { double an=0; int a,i=1; cin>>a; while(an<=a) { an+=1.0/i; i++; } cout<<i-1; return 0; }
- 
  0@ 2024-09-15 12:48:54#include <bits/stdc++.h> 
 using namespace std;
 int main(){
 int n;
 cin >> n;
 double res = 0;
 for(int i = 1 ;; i++){
 double r1 = 1 * 1.00000 / i * 1.00000;
 res += r1;
 if(res > n){
 cout << i << endl;
 return 0;
 }} 
 }//直接枚举
- 
  0@ 2022-04-10 08:16:56#include<iostream> 
 using namespace std;
 int main(){
 int k;
 cin>>k;
 double Sn=0;
 int i=0;
 while(Sn<=k){
 i++;
 Sn+=1.0/i;
 }
 cout<<i<<endl;
 return 0;
 }
- 
  0@ 2022-04-10 08:16:05#include<iostream> 
 using namespace std;
 int main(){
 int k;
 cin>>k;
 double Sn=0;
 int i=0;
 while(Sn<=k){
 i++;
 Sn+=1.0/i;
 }
 cout<<i<<endl;
 return 0;
 }
- 
  0@ 2022-04-07 20:45:46#include<iostream> using namespace std; int a,b,c; double d; int main() { cin>>a; int i=1; while(d<=a) { d+=1.0/i; i++; } cout<<i-1; return 0; }
- 
  0@ 2022-01-16 10:30:40思路:1.这道题无法判断要执行多少次,因此要用 while循环. ~~for(;;)表示不服~~2.题目问的是大于k,因此**终止**条件应该是 sum>k,也就是说循环条件应该是sum<=k.3.还要注意一些 while循环的+1-1代码:#include<iostream> #include<cstdio> using namespace std; int k,n; double sum;//sum用于表示当前的和 int main(){ scanf("%d",&k); while(sum<=k)//是小于等于,不是小于 sum+=1.0/++n;//1.0将答案转为double类型 /* 也可以写成sum+=1.0/n++ 但这样写的话n要赋初值1 其实就等于 n++; sum+=1.0/n; */ printf("%d",n); return 0; }
- 
  0@ 2021-07-23 08:49:58#include<bits/stdc++.h>//万能头文件 
 using namespace std;
 double x;
 int s,i;
 //把变量定义成全局变量,变量一开始值都是0
 int main(){
 cin>>s;//输入
 for(i=1;;i++){
 x=x+1.0*1/i;//累加
 if(x>s)break;//达到条件后就可以退出循环了
 }
 cout<<i;//输出
 return 0;//在NOIP考场上,不写return 0会爆0的!!!所以return 0很重要!
 }
- 
  0@ 2020-03-31 17:15:53#include<iostream> 
 using namespace std;
 int main(){
 double S=0;
 int k,n=1;
 cin>>k;
 while(S<=k){
 S+=1.0/n;
 n++;
 }
 cout<<n-1;
 }
- 
  0@ 2020-03-17 19:03:20#include<iostream> using namespace std; int main () { int k, n = 1; double sn = 0; cin >> k; while(sn <= k) { sn += 1.0/n; n++; } cout << n - 1 << endl; return 0; }
- 
  0@ 2019-06-17 13:50:22#include <iostream> 
 using namespace std;
 int main(void)
 {
 double k, n = 1.0, all = 0.0;
 cin >> k;
 while (all <= k) {
 all += (1 / n);
 ++n;
 }
 cout << (--n);
 return 0;
 }
- 
  0@ 2019-01-02 19:03:39#include<iostream> #include<cstdio> using namespace std; int main() { int n=1;double s=1,k; scanf("%lf",&k); do { n++; s+=1.00/n; } while(s<=k); cout<<n<<endl; return 0; }
- 
  0@ 2018-12-29 21:00:50还行,只要用到iostream就行。 
 c++#include <iostream> using namespace std ; int n ; double a[10000] , k ; int main() { cin >> n ; for ( int i = 1 ; /*sb*/ ; i ++ ) { k += 1.0 / i ; if ( k > n ) { cout << i << endl ; return 0 ; } } return 0 ; }
- 
  0@ 2018-11-03 20:55:18Pascal代码 
 var
 s:real;
 k,i:longint;
 begin
 read(k);
 while s<=k do
 begin
 inc(i);
 s:=s+1/i;
 end;
 write(i);
 end.
- 
  0@ 2018-10-01 22:05:34p党来了。 
 var
 k,s:real;
 i:longint;
 begin
 read(k);
 while s<k do
 begin
 i:=i+1;
 s:=s+1/i;
 end;
 write(i);
 end.
- 
  0@ 2018-09-13 20:19:22#include<bits/stdc++.h> 
 using namespace std;
 int main()
 {
 double i=1,n=0,k;
 cin>>k;
 for(i=1;i>0;)
 {
 n+=1/i;
 if(n<=k)
 i++;
 else break;
 }
 cout<<i;
 return 0;
 }
- 
  0@ 2018-09-05 21:22:21lo 
 ```cpp
 #include<iostream>
 using namespace std;int main(){ 
 int k;
 double tot,i;
 cin>>k;
 i=0.00000;
 tot=0.00000;
 while(tot<=k){
 i++;
 tot+=1/i;
 }
 cout<<i<<endl;
 }
 ```
- 
  0@ 2018-08-08 19:13:46Pascal党,请注意查收 
 var i,K:longint;
 Sn:real;
 begin
 readln(K);
 Sn:=0;
 i:=0;
 while Sn<=K do
 begin
 inc(i);
 Sn:=Sn+1/i;
 end;
 writeln(i);
 end.