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;
}

总结

水题,不解释

目录
相关文章
|
8月前
|
机器学习/深度学习 数据采集 分布式计算
大数据分析中的机器学习基础:从原理到实践
大数据分析中的机器学习基础:从原理到实践
382 3
|
8月前
|
机器学习/深度学习 计算机视觉
RT-DETR改进策略【Neck】| NeurIPS 2023 融合GOLD-YOLO颈部结构,强化小目标检测能力
RT-DETR改进策略【Neck】| NeurIPS 2023 融合GOLD-YOLO颈部结构,强化小目标检测能力
175 17
RT-DETR改进策略【Neck】| NeurIPS 2023 融合GOLD-YOLO颈部结构,强化小目标检测能力
|
7月前
|
人工智能 文字识别 自然语言处理
1.6K star!这个开源文本提取神器,5分钟搞定PDF/图片/Office文档!
Kreuzberg 是一个基于 Python 的文本提取库,支持从 PDF、图像、Office 文档等 20+ 格式中提取文本内容。采用 MIT 开源协议,具备本地处理、异步架构、智能 OCR 等特性,特别适合需要隐私保护的文档处理场景。
585 1
|
iOS开发
如何识别手机是否有灵动岛(dynamic island)
如何识别手机是否有灵动岛(dynamic island)
638 0
|
12月前
|
人工智能 算法 数据可视化
智慧停车场车位引导及反向寻车解决方案
智慧停车场导航系统结合了先进的室内定位技术和导航算法,旨在解决大型公共场所停车难、找车难等问题。系统不仅提供精准的停车引导、反向寻车及停车场内导航服务,还通过大数据分析优化停车场管理和用户体验,是提升现代城市智能化水平的重要组成部分。
1118 0
|
Java 关系型数据库 MySQL
连接池技术:简单而强大的加速数据库访问方法
连接池技术是一种简单而强大的方法,可用于加速数据库访问。在传统的数据库访问过程中,每次与数据库建立连接和关闭连接都需要耗费大量的时间和资源。而连接池技术通过事先建立一组可重复使用的数据库连接,有效地减少了连接和关闭连接的开销。本文将深入探讨连接池技术的工作原理和优势,以及如何正确配置和使用连接池来提高应用程序的性能。无论你是开发人员还是系统管理员,通过了解连接池技术,你将能够更好地利用数据库资源,使系统更加稳定和高效。
973 0
|
机器学习/深度学习 边缘计算 PyTorch
PyTorch 与 ONNX:模型的跨平台部署策略
【8月更文第27天】深度学习模型的训练通常是在具有强大计算能力的平台上完成的,比如配备有高性能 GPU 的服务器。然而,为了将这些模型应用到实际产品中,往往需要将其部署到各种不同的设备上,包括移动设备、边缘计算设备甚至是嵌入式系统。这就需要一种能够在多种平台上运行的模型格式。ONNX(Open Neural Network Exchange)作为一种开放的标准,旨在解决模型的可移植性问题,使得开发者可以在不同的框架之间无缝迁移模型。本文将介绍如何使用 PyTorch 将训练好的模型导出为 ONNX 格式,并进一步探讨如何在不同平台上部署这些模型。
1280 2
|
JSON 分布式计算 大数据
MaxCompute产品使用合集之大数据计算MaxCompute 要提取JSON字符串中的所有key-value对,我该怎么操作
MaxCompute作为一款全面的大数据处理平台,广泛应用于各类大数据分析、数据挖掘、BI及机器学习场景。掌握其核心功能、熟练操作流程、遵循最佳实践,可以帮助用户高效、安全地管理和利用海量数据。以下是一个关于MaxCompute产品使用的合集,涵盖了其核心功能、应用场景、操作流程以及最佳实践等内容。
|
消息中间件 负载均衡 Java
【Kafka】Kafka 中消费者与消费者组的关系与负载均衡实现
【4月更文挑战第11天】【Kafka】Kafka 中消费者与消费者组的关系与负载均衡实现
|
安全 Linux Shell
Linux服务器配置SSH免密码登录后,登录仍提示输入密码(一次真实的问题排查解决记录)
Linux服务器配置SSH免密码登录后,登录仍提示输入密码(一次真实的问题排查解决记录)
930 0