Sum of Round Numbers

简介: Sum of Round Numbers

文章目录

一、Sum of Round Numbers

总结


一、Sum of Round Numbers

本题链接:Sum of Round Numbers


题目:

A. Sum of Round Numbers

time limit per test1 second

memory limit per test256 megabytes

inputstandard input

outputstandard output

A positive (strictly greater than zero) integer is called round if it is of the form d00...0. In other words, a positive integer is round if all its digits except the leftmost (most significant) are equal to zero. In particular, all numbers from 1 to 9 (inclusive) are round.


For example, the following numbers are round: 4000, 1, 9, 800, 90.The following numbers are not round: 110, 707, 222, 1001.


You are given a positive integer n (1≤n≤1e4). Represent the number n as a sum of round numbers using the minimum number of summands (addends). In other words, you need to represent the given number n as a sum of the least number of terms, each of which is a round number.


Input

The first line contains an integer t (1≤t≤1e4) — the number of test cases in the input. Then t test cases follow.


Each test case is a line containing an integer n (1≤n≤1e4).


Output

Print t answers to the test cases. Each answer must begin with an integer k — the minimum number of summands. Next, k terms must follow, each of which is a round number, and their sum is n. The terms can be printed in any order. If there are several answers, print any of them.


Example

input

5

5009

7

9876

10000

10

output

2

5000 9

1

7

4

800 70 6 9000

1

10000

1

10

本博客给出本题截图


image.png

题意:把一个数的每一位按照如下例子拆分出来,例如9872 = 9000 + 800 + 70 + 2,输出拆分后的数字的个数和这些数字,对于这个例子我们需要输出4(拆开后4个数),9000 800 70 2

AC代码

#include <iostream>
#include <string>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t -- )
    {
        string a;
        cin >> a;
        int cnt = 0;
        for (int i = 0; i < a.size(); i ++ )
            if (a[i] != '0') 
                cnt ++;
        cout << cnt << endl;
        for (int i = 0; i < a.size(); i ++ )
        {
            if (a[i] == '0') continue;
                cout << a[i];
            for (int j = i; j < a.size() - 1; j ++ )
                cout << 0;
            cout << ' ';
        }
        puts("");
    }
    return 0;
}

总结

水题,不解释

目录
相关文章
|
分布式计算 API Linux
通义千问API:找出两篇文章的不同
本章我们将介绍如何利用大模型开发一个文档比对小工具,我们将用这个工具来给互联网上两篇内容相近但版本不同的文档找找茬,并且我们提供了一种批处理文档比对的方案
|
存储 消息中间件 缓存
9 个 FastAPI 的必知资源
FastAPI 是 Python 开发人员最新、最流行的 API 框架之一。我们的工程师一次又一次需要将一个或多个第三方库与我们的 API 结合使用,以附加额外的功能和特性来丰富我们的项目。
1550 0
|
人工智能 文字识别 自然语言处理
1.6K star!这个开源文本提取神器,5分钟搞定PDF/图片/Office文档!
Kreuzberg 是一个基于 Python 的文本提取库,支持从 PDF、图像、Office 文档等 20+ 格式中提取文本内容。采用 MIT 开源协议,具备本地处理、异步架构、智能 OCR 等特性,特别适合需要隐私保护的文档处理场景。
1590 1
|
人工智能 算法 数据可视化
智慧停车场车位引导及反向寻车解决方案
智慧停车场导航系统结合了先进的室内定位技术和导航算法,旨在解决大型公共场所停车难、找车难等问题。系统不仅提供精准的停车引导、反向寻车及停车场内导航服务,还通过大数据分析优化停车场管理和用户体验,是提升现代城市智能化水平的重要组成部分。
1820 19
|
机器学习/深度学习
清华领衔发布多模态评估MultiTrust:GPT-4可信度有几何?
【8月更文挑战第16天】近日,清华大学等机构发布了MultiTrust多模态评估研究,旨在全面评估大型语言模型的可信度。这是首个统一的多模态基准,覆盖真实性、安全性等五大方面,包含32个任务。研究对21个现代模型进行了实验,揭示了可信度问题和风险,强调了提高模型可靠性的重要性。结果显示开源模型在可信度上落后于专有模型,特别是在安全性方面。此外,研究还发现了模型在鲁棒性、公平性和隐私方面的挑战。论文已发布于arxiv.org。
391 1
|
机器学习/深度学习 人工智能 自然语言处理
ICML 2024 Spotlight:在解码中重新对齐,让语言模型更少幻觉、更符合人类偏好
【7月更文挑战第13天】ICML 2024 Spotlight: Decoding-time Realignment改善语言模型,减少幻觉,增强人类偏好一致性。研究提出在解码阶段动态调整模型对齐,通过控制参数实现对齐与性能平衡,提高泛化能力。尽管面临参数选择及计算资源挑战,该技术为优化AI文本生成对齐提供了新途径。[论文链接](https://openreview.net/forum?id=n8g6WMxt09&noteId=E3VVDPVOPZ)**
447 9
|
安全 C++
C++一分钟之-字符串处理:std::string
【6月更文挑战第25天】`std::string`是C++文本处理的核心,存在于`&lt;string&gt;`库中。它支持初始化、访问、连接、查找、替换等操作。常见问题包括空指针解引用、越界访问和不当内存管理。要安全使用,确保字符串初始化,用`at()`检查边界,用`.empty()`检查空字符串,且无需手动释放内存。高效技巧包括预先分配内存、利用互转函数以及使用迭代器。记得正确比较和遍历字符串以保证代码效率和安全性。
625 5
|
编解码 人工智能 自然语言处理
MaskGCT:登上GitHub趋势榜榜首的TTS开源大模型
近日,香港中文大学(深圳)联手趣丸科技推出了新一代大规模声音克隆TTS模型——MaskGCT。一起看看该模型的一些表现吧!
|
安全 Linux Shell
Linux服务器配置SSH免密码登录后,登录仍提示输入密码(一次真实的问题排查解决记录)
Linux服务器配置SSH免密码登录后,登录仍提示输入密码(一次真实的问题排查解决记录)
1199 0
|
运维 供应链 搜索推荐
服装店库存管理系统 毕业设计 JAVA+Vue+SpringBoot+MySQL(一)
服装店库存管理系统 毕业设计 JAVA+Vue+SpringBoot+MySQL
620 0