B. The Secret Number

time limit per test

2 seconds

memory limit per test

256 megabytes

Vadim has thought of a number x. To ensure that no one can guess it, he appended a positive number of zeros to the right of it, thus obtaining a new number y. However, as a precaution, Vadim decided to spread the number n=x+y. Find all suitable x that Vadim could have thought of for the given n.

Input

Each test consists of several test cases. The first line contains a single integer t (1≤t≤104) --- the number of test cases. The following lines describe the test cases.

In a single line of each test case, there is an integer n --- the number spread by Vadim (11≤n≤1018).

Output

For each number n, output 0 if there are no suitable x. Otherwise, output the number of suitable x, followed by all suitable x in ascending order.

Example

Input

Copy

复制代码

5

1111

12

55

999999999999999999

1000000000000000000

Output

Copy

复制代码
2
11 101
0
1
5
3
999999999 999000999000999 90909090909090909
0

Note

In the first sample, to 11 one can append two zeros to the right, then 11+1100=1111, and to 101 one can append one zero to the right, then 101+1010=1111.

In the second sample, it is impossible to obtain 12 through the described actions.

解题说明:此题是一道数学题,给出一个N,是否能找出一个X,使得X+Y=N,其中Y = X ∗ 10 ^K,求解X+X ∗ 10 ^K=N。 因为N范围小于10^18次方,因此K最多为18.直接求解即可。

cpp 复制代码
#include <stdio.h>
int main()
{
	long long t; 
	scanf("%lld", &t);
	while (t--) 
	{
		long long n; 
		scanf("%lld", &n);
		long long test = 1, testt[64];
		int cnt = 0;
		for (int k = 1; k <= 18; k++)
		{
			test *= 10;
			long long d = test + 1;
			if (n % d == 0)
			{
				testt[cnt++] = n / d;
			}
		}
		if (cnt == 0) 
		{
			printf("0\n");
			continue;
		}
		printf("%d\n", cnt);
		for (int i = cnt - 1; i >= 0; i--)
		{
			printf("%lld", testt[i]);
			if (i)
			{
				printf(" ");
			}
		}
		printf("\n");
	}
	return 0;
}
相关推荐
weisian15139 分钟前
Java并发编程--47-分布式ID生成器:雪花算法(Snowflake)与时钟回拨问题
java·算法·时钟回拨·雪花算法id
itzixiao40 分钟前
L1-066 猫是液体(5分)[java][python]
java·开发语言·python·算法
ytttr87341 分钟前
MATLAB SIFT图像配准实现
算法·机器学习·matlab
小饕1 小时前
从 Word2Vec 到多模态:词嵌入技术的演进全景
人工智能·算法·机器学习
海参崴-1 小时前
AVL树完整实现与深度解析
算法
一个爱编程的人1 小时前
一个数是不是素数
数据结构·算法
Hui_AI7201 小时前
基于RAG的农产品GEO溯源智能问答系统实现
开发语言·网络·人工智能·python·算法·创业创新
lwf0061641 小时前
FFM (Field-aware Factorization Machine) 学习日记
算法·机器学习
南宫萧幕1 小时前
HEV能量管理控制算法实战:从MPC/RL理论基础到Simulink闭环建模
算法·matlab·汽车·控制·pid
IT猿手1 小时前
SCI一区:章鱼优化算法(Octopus Optimization Algorithm, OOA)求解23个测试函数,出图丰富,提供完整MATLAB代码
开发语言·算法·matlab