All pastes #732934 Raw Edit

Unnamed

public cpp v1 · immutable
·published 2007-10-11 12:08 UTC
rendered paste body
#include <iostream>using namespace std;int maxDepth, steps, bestSteps;int doit(const string& s, int curDep, int i){  if (s[i] == '0') return 1;  ++steps;  if (++curDep > maxDepth)    maxDepth = curDep, bestSteps = steps;  int l = 1 + doit(s, curDep, i + 1);  return l + doit(s, curDep, i + l);}int main(){  string s;  for (int c = 0; c < 10; ++c) {    cin >> s; cin >> s;    maxDepth = -1, steps = 0, bestSteps = -1;    doit(s, 0, 0);    cout << bestSteps << endl;  }}