Advertisement
Nazmul19285

A. Sum of Round Numbers

Jun 21st, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include <sstream>
  4. #include <vector>
  5. #include <cmath>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     int a,b;
  11.     cin>>a;
  12.     for(int i=1;i<=a;i++){
  13.         int c=0,k;
  14.         cin>>b;
  15.         ostringstream ss;
  16.         ss<<b;
  17.         string g=ss.str();
  18.         vector <int> v;
  19.         for(int j=g.size()-1;j>=0;j--){
  20.             if(g[j]=='0'){
  21.                 c++;
  22.             }
  23.             else{
  24.                 k=pow(10,c)+0.5;
  25.                 string p(1, g[j]);
  26.                 stringstream ee(p);
  27.                 int x=0;
  28.                 ee>>x;
  29.                 k=k*x;
  30.                 v.push_back(k);
  31.                 c++;
  32.             }
  33.         }
  34.         cout<<v.size()<<endl;
  35.         for(int j=0;j<v.size();j++){
  36.             if(j==v.size()-1){
  37.                 cout<<v[j]<<endl;
  38.             }
  39.             else{
  40.                 cout<<v[j]<<" ";
  41.             }
  42.         }
  43.  
  44.     }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement