-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1769.cpp
More file actions
48 lines (43 loc) · 705 Bytes
/
1769.cpp
File metadata and controls
48 lines (43 loc) · 705 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
// 1769. 3의 배수
// 2021.10.02
// 구현
#include<iostream>
#include<string>
using namespace std;
int main()
{
string s;
cin >> s;
int cnt = 0;
long long tmp = 0;
if (s.size() >= 2)
{
while (1)
{
tmp = 0;
for (auto k : s)
{
tmp += k - '0';
}
cnt++;
if (tmp < 10)
{
break;
}
s = to_string(tmp);
}
}
else
{
tmp = stol(s);
}
if (tmp % 3 == 0)
{
cout << cnt << endl << "YES" << endl;
}
else
{
cout << cnt << endl << "NO" << endl;
}
return 0;
}