All pastes #732924 Raw Edit

Mine

public cpp v1 · immutable
·published 2007-10-11 11:58 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;  ++curDep;  if (curDep > maxDepth)  {    maxDepth = curDep;    bestSteps = steps;  }  int l = 1;  l += doit(s, curDep, i + l);  l += doit(s, curDep, i + l);  return 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;  }}