forked from b-chae/AlgorithmStudy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4539.cpp
More file actions
45 lines (36 loc) · 601 Bytes
/
Copy path4539.cpp
File metadata and controls
45 lines (36 loc) · 601 Bytes
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
#include <iostream>
#include <vector>
using namespace std;
int T;
vector<int> N;
vector<int> ans;
int main()
{
int i;
cin >> T;
for (i = 0; i < T; i++) {
int tmp;
cin >> tmp;
N.push_back(tmp);
}
for (i = 0; i < T; i++) {
int tmp = N[i];
int n = N[i];
int digits = 10;
while (n >= 10) {
int last_digit = n % 10;
if (last_digit >= 5) {
tmp = tmp + digits - last_digit * (digits / 10);
}
else {
tmp = tmp - last_digit * (digits/10);
}
digits *= 10;
n = tmp / (digits/10);
}
ans.push_back(tmp);
}
for (int i : ans) {
cout << i << " ";
}
}