2 条题解

  • 1
    @ 2026-9-10 16:33:29
    #include <bits/stdc++.h>
    using namespace std;
    double sum, n, i = 1;
    
    int main() {
    	cin >> n;
    	while (sum <= n) {
    		sum += 1 / i;
    		if (sum > n) {
    			cout << i << endl;
    			break;
    		}
    		i++;
    	}
    	return 0;
    }
    
    • 0
      @ 2026-8-6 10:21:19
      #include <bits/stdc++.h>
      using namespace std;
      
      int main() {
      	int k, n;
      	double s = 0;
      	cin >> k;
      	for (int i = 1; i < 100000000; i++) {
      		s = s + 1.0 / i;
      		if (s > k) {
      			cout << i;
      			break;
      		}
      	}
      	return 0;
      }
      
      
      
      • 1

      信息

      ID
      5157
      时间
      1000ms
      内存
      512MiB
      难度
      1
      标签
      递交数
      59
      已通过
      23
      上传者