全部评论 6

  • 1年后回来看黑历史......

    2025-04-17 来自 江苏

    0
    • 历练了,恭喜

      #include<iostream>
      using namespace std;
      
      long long n,cnt = 0,ans = 0;
      long long a[10000010];
      
      int main(){
      	long long apple = 1; 
      	cin >> n;
      	while(cnt + apple <= n){
      		a[ans] = apple;
      		ans++; 
      		cnt += apple;
      		apple *= 2;
      	}
      	cout << ans << endl;
      	for(int i = 0;i < ans;i++){
      		cout << a[i] << endl;
      	} 
      	return 0;
      }
      

      13小时前 来自 浙江

      0
  • n的数据比较大,你用for循环还不优化,时间复杂度干到O(n),当然会超时,建议优化一下循环部份

    2023-12-30 来自 广东

    0
    • userId_undefined

      HUDSI

      回复NULL

      麻烦大佬看一下啥时候发的

      2023-12-30 来自 江苏

      0
    • userId_undefined

      NULL

      回复HUDSI

      想评论一下不行吗

      2023-12-30 来自 广东

      0
    • userId_undefined

      HUDSI

      回复NULL

      额。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

      2023-12-30 来自 江苏

      0
  • 帮你改了一下

    2023-12-29 来自 上海

    0
  • #include <bits/stdc++.h>
    using namespace std;
    int main(){
    long long n,h,sum=1;
    cin>>n,h;
    for(long long a=1;a<=n;a){
    sum*=2;
    a+=sum;
    h+=1;
    }
    cout<<h<<endl;

    2023-12-29 来自 上海

    0
    • userId_undefined

      HUDSI

      回复人`

      你看下我啥时候发的(但还是谢谢)

      2023-12-29 来自 江苏

      0
    • userId_undefined

      人`

      回复HUDSI

      2023-12-29 来自 上海

      0
    • userId_undefined

      HUDSI

      回复人`

      现在都学算法了

      2023-12-29 来自 江苏

      0
  • 练习1月半之后看题是多么简单

    2023-12-29 来自 江苏

    0
  • n要longlong

    2023-11-04 来自 江西

    0

热门讨论