Codeforces Round 640 Div 4 Solution:
Problem Statement Link --> Status - Codeforces
Solution in JAVA:
import java.util.*;
public class test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int i = 0; i < t; i++) {
int num = sc.nextInt();
List<Integer> terms = new ArrayList<>();
int multiplier = 1;
while (num > 0) {
int digit = num % 10;
if (digit > 0) {
terms.add(digit * multiplier);
}
num /= 10;
multiplier *= 10;
}
System.out.println(terms.size());
for (int term : terms) {
System.out.print(term + " ");
}
System.out.println();
}
sc.close();
}
}
No comments:
Post a Comment