Advertisement
sazid_iiuc

Untitled

May 10th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int testcase;
  7.     cin >> testcase;
  8.     while (testcase--)
  9.     {
  10.         int input, temp,temp2, particle = 1, factor = 1, fact_temp=1, result;
  11.  
  12.         cin >> input;
  13.         temp = input;
  14.         while (temp)
  15.         {
  16.             temp = temp / 10;
  17.             fact_temp = fact_temp * 10;
  18.         }
  19.         temp2=input;
  20.         factor=fact_temp;
  21.         while (factor > 1)
  22.         {
  23.             factor = factor / 10;
  24.             result = temp2 / factor;
  25.             if (result * factor != 0)
  26.             {
  27.                 particle++;
  28.             }
  29.             temp2 = temp2 % factor;
  30.         }
  31.         cout << particle - 1 << endl;
  32.         while (fact_temp > 1)
  33.         {
  34.             fact_temp = fact_temp / 10;
  35.             result = input / fact_temp;
  36.             if (result * fact_temp != 0)
  37.             {
  38.                 cout << result * fact_temp << " ";
  39.             }
  40.             input = input % fact_temp;
  41.         }
  42.         cout << endl;
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement