acgo题库
  • 首页
  • 题库
  • 学习
  • 竞赛
  • 讨论
  • 排行
  • 团队
  • 备赛专区

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
登录
注册
题目详情提交记录(0)
  • 题解

    userId_undefined

    zsy

    7月全勤卷王8月全勤卷王题解仙人时空双修者秩序白银快乐小狗
    27阅读
    0回复
    2点赞
  • 更简单

    #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

    宇彤

    时间刺客模拟·模拟练习生递归·套娃学徒枚举·枚举小能手贪心·贪心尝试者字符串·魔法使
    2阅读
    0回复
    0点赞
  • 很简单

    #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

    蝴蝶刀.冷锋

    倔强青铜模拟·模拟练习生递归·套娃学徒贪心·贪心尝试者
    9阅读
    0回复
    2点赞
  • 另类TJ

    userId_undefined

    ☆𝑬-𝑳𝑨𝑹☆

    7月全勤卷王出道萌新模拟·模拟练习生数组·数组操作员循环·循环打卡人字符串·魔法使
    14阅读
    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

    宇彤

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

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

首页