-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1352A-Sum of Round Numbers.cpp
59 lines (40 loc) · 1.09 KB
/
1352A-Sum of Round Numbers.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <bits/stdc++.h>
using namespace std;
int main(){
int t{0};
cin >> t;
for(int i=0;i<t; i++){
vector<int> cnute;
// test case = 9876
int n{0};
cin >> n;
if(n%10 != 0){
cnute.push_back(n%10); // 9876 % 10 = 6
}
int ans = n%10; // = 6
n = n-ans; // 9876-6 = 9870
if(n%100 != 0){
cnute.push_back(n%100); // 9870 % 100 = 70
}
ans = n%100; // = 70
n = n- ans; // 9870-70 = 9800
if(n%1000 != 0){
cnute.push_back(n%1000);// 9800%1000 = 800
}
ans = n%1000; // = 800
n = n- ans; // 9800-800 = 9000
if(n%10000!=0)
{
cnute.push_back(n%10000);
}
if(n>=10000 && n%10000==0)
{
cnute.push_back(n);
}
cout << cnute.size() << endl;
for(int i=0; i<cnute.size(); i++){
cout << cnute[i] << " ";
}
cout << endl;
}
}