构造数列——AcWing 4861

#include <iostream>

using namespace std;

int main()
{
    int T;
    cin >> T;
    while (T -- )
    {
        string s;
        int res = 0;
        cin >> s;
        for (auto c: s)
            if (c != '0')
                res ++ ;
        cout << res << endl;
        
        for (int i = s.size() - 1, t = 1; i >= 0; t *= 10, i -- )
            if (s[i] != '0')
                cout << (s[i] - '0') * t << ' ';
        puts("");
    }
    
    return 0;
}
#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;
    while (t -- )
    {
        int x;
        cin >> x;

        int res = 0;
        if (x < 10 || x == 10000) cout << 1 << endl << x << endl;
        else 
        {
            int a = x % 10;
                x /= 10;
            int b = x % 10;
                x /= 10;
            int c = x % 10;
                x /= 10;
            int d = x % 10;

            if (a != 0) res ++ ;
            if (b != 0) res ++ ;
            if (c != 0) res ++ ;
            if (d != 0) res ++ ;
            cout << res << endl;

            if (a != 0) cout << a << ' ';
            if (b != 0) cout << b * 10 << ' ';
            if (c != 0) cout << c * 100 << ' ';
            if (d != 0) cout << d * 1000 << ' ';
            cout << endl;
        }
    }
    return 0;
}

作者:我是java同学
链接:https://www.acwing.com/solution/content/170716/
来源:AcWing
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值