Skip to content

Commit cddea54

Browse files
committed
learned math
1 parent 4bdd0bc commit cddea54

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

B_Sum_of_Digits.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
////https://codeforces.com/contest/102/problem/B
2+
#include <bits/stdc++.h>
3+
using namespace std;
4+
typedef long long ll;
5+
const int mod = 1e9 + 7;
6+
const int N = 1e5 + 5;
7+
8+
void solve()
9+
{
10+
string s;
11+
cin >> s;
12+
int count = 0;
13+
14+
while (s.size() > 1)
15+
{
16+
ll sum = 0;
17+
for (char c : s)
18+
{
19+
sum += c - '0';
20+
}
21+
count++;
22+
23+
s = to_string(sum);
24+
}
25+
cout << count << endl;
26+
}
27+
28+
int main()
29+
{
30+
ios_base::sync_with_stdio(0);
31+
cin.tie(0);
32+
solve();
33+
}

0 commit comments

Comments
 (0)