acgo题库
  • 首页
  • 题库
  • 学习
  • 天梯
  • 备赛

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
  • 竞赛
  • 讨论
  • 团队
  • 商城
登录
注册
题目详情提交记录(0)
  • 题解

    userId_undefined
    zsy
    秩序白银时空双修者题解仙人快乐小狗BUG超度大师
    42阅读
    0回复
    2点赞
  • 很简单

    #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; while (n) { if(n % 2 == 0) s = "0" + s; else s = "1" + s; n /= 2; } for(int i = s.size() - 1, j = 0; i >= 0; i--, j ++){ if(s[i]=='1')cout<<j<<endl; } }

    userId_undefined
    用毒毒毒蛇,毒蛇会被毒毒死吗
    倔强青铜模拟·模拟练习生递归·套娃学徒贪心·贪心尝试者
    25阅读
    0回复
    2点赞
  • 另类TJ

    userId_undefined
    ☆𝑬-𝑳𝑨𝑹☆
    7月全勤卷王快乐小狗枚举·枚举小能手结构体学徒→封装者多键裁决者冒泡宗师→排序元老
    21阅读
    0回复
    1点赞
  • 更简单

    #include<bits/stdc++.h> using namespace std; string change(int x){ string s; while(x != 0){ s += x % 2 + 48; //等于s += x % 2 + '0'; x /= 2; } return s; } int main(){ int n; cin>>n; string s = change(n); for(int i = 0 ; i < s.size() ; i++){ if(s[i] == '1')cout << i << endl; } return 0; }

    userId_undefined
    星宇同晨
    时间刺客字符串·魔法使模拟·模拟练习生递归·套娃学徒枚举·枚举小能手贪心·贪心尝试者
    9阅读
    0回复
    1点赞
  • 很短

    #include <bits/stdc++.h> using namespace std; int n; void change(int x){ string s; while(x>0){ s+=x%2+'0'; x/=2; } for(int i=0;i<s.size();i++){ if(s[i]=='1'){ cout<<i<<endl; } } } int main(){ cin>>n; change(n); }

    userId_undefined
    星宇同晨
    时间刺客字符串·魔法使模拟·模拟练习生递归·套娃学徒枚举·枚举小能手贪心·贪心尝试者
    7阅读
    0回复
    1点赞
暂无数据

提交答案之后,这里将显示提交结果~

首页