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;
}
相关推荐
xhbaitxl3 分钟前
算法学习day39-动态规划
学习·算法·动态规划
I_LPL5 分钟前
day23 代码随想录算法训练营 回溯专题2
算法·hot100·回溯算法·求职面试
智者知已应修善业6 分钟前
【洛谷P9975奶牛被病毒传染最少数量推导,导出多样例】2025-2-26
c语言·c++·经验分享·笔记·算法·推荐算法
m0_7369191022 分钟前
C++中的委托构造函数
开发语言·c++·算法
小小小小王王王28 分钟前
洛谷-P1886 【模板】单调队列 / 滑动窗口
c++·算法
PPPPPaPeR.1 小时前
光学算法实战:深度解析镜片厚度对前后表面折射/反射的影响(纯Python实现)
开发语言·python·数码相机·算法
看我干嘛!1 小时前
python第五次作业
算法
历程里程碑1 小时前
Linux 库
java·linux·运维·服务器·数据结构·c++·算法
Sheep Shaun1 小时前
如何让一个进程诞生、工作、终止并等待回收?——探索Linux进程控制与Shell的诞生
linux·服务器·数据结构·c++·算法·shell·进程控制
Pluchon1 小时前
硅基计划4.0 简单模拟实现AVL树&红黑树
java·数据结构·算法