1 条题解

  • 0
    @ 2025-4-12 22:06:18

    C++ :

    #include <iostream>  
    using namespace std;  
    int main(){  
        int i = 1,n,x;
        double s = 0;
        cin>>x;
         while(s <= x){ 
       s = s + 1.0 / i;
       i++;
    }
    cout<<i - 1<<endl;
        return 0;  
      } 
    
    

    Python :

    x = int(input())
    s = 0
    i = 1
    while True:
        s += 1 / i
        if s > x:
            print(i)
            break
        i += 1
    
    • 1

    信息

    ID
    2976
    时间
    1000ms
    内存
    16MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者