Advertisement
MiinaMagdy

11687 - Digits

Sep 3rd, 2022
897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. /*
  2.  *
  3.  * problem link: https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&category=0&problem=2734&mosmsg=Submission+received+with+ID+27782167
  4.  *  
  5.  * */
  6.  
  7. #include <bits/stdc++.h>
  8.  
  9. using namespace std;
  10.  
  11. #define ll long long
  12. #define endl '\n'
  13. #define sz(x) int(x.size())
  14. #define all(x) x.begin(), x.end()
  15.  
  16. int main() {
  17.     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  18.  
  19.     string s;
  20.     while (cin >> s, s != "END") {
  21.         string prev = "0";
  22.         int i = 0;
  23.         if (s != "1")
  24.         while (sz(s) != stoi(prev)) {
  25.             prev = to_string(sz(s));
  26.             s = prev;
  27.             i++;
  28.         }
  29.         cout << i + 1 << endl;
  30.     }
  31. }
  32.  
Tags: UVA CP3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement