v 0. Pasted by slipstak2 as cpp at 2015-01-23 05:31:42 MSK and set expiration to never.

Paste will expire never.

  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int find1(int n) {
  6.     int cnt = 0;
  7.     while (n) {
  8.         cnt += (n%10 == 1);
  9.         n /= 10;
  10.     }
  11.     return cnt;
  12. }
  13. int main() {
  14. #ifdef _DEBUG
  15.     freopen("input.txt","r",stdin);
  16.     freopen("output.txt","w",stdout);
  17. #endif
  18.  
  19.     int num = 0;
  20.     char c;
  21.     while (cin>>c) {
  22.         if (c == '1') {
  23.             ++num;
  24.         }
  25.     }
  26.     while (num > 1) {
  27.         num = find1(num);
  28.     }
  29.     cout<<num;
  30.     return 0;
  31. }


Editing is locked.