-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3062.cpp
More file actions
54 lines (49 loc) · 854 Bytes
/
3062.cpp
File metadata and controls
54 lines (49 loc) · 854 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
46
47
48
49
50
51
52
53
54
// 3062. 수 뒤집기
// 2021.05.22
// 수학
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int reverseInt(int n)
{
int result = 0;
while (n > 0)
{
result += n % 10;
result *= 10;
n /= 10;
}
result /= 10;
return result;
}
int main()
{
int n;
int k;
cin >> n;
while (n-- > 0)
{
cin >> k;
int sum = k + reverseInt(k);
string s = to_string(sum);
bool flag = true;
for (int i = 0; i <= s.size() / 2; i++)
{
if (s[i] != s[s.size() - 1 - i])
{
flag = false;
break;
}
}
if (flag)
{
cout << "YES" << endl;
}
else
{
cout << "NO" << endl;
}
}
return 0;
}