All pastes #732936 Raw Edit

Anonymous

public cpp v1 · immutable
·published 2007-10-11 12:13 UTC
rendered paste body
#include <iostream>int maxDepth, steps, bestSteps;int doit(const std::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(){  std::string s;  for (int c = 0; c < 10; ++c) {    std::cin >> s, std::cin >> s, maxDepth = -1, steps = 0, bestSteps = -1;    doit(s, 0, 0), std::cout << bestSteps << std::endl;  }}