Skip to content

Instantly share code, notes, and snippets.

@msly
Last active June 20, 2016 03:27
Show Gist options
  • Select an option

  • Save msly/80d99b06c6143bae8c3a to your computer and use it in GitHub Desktop.

Select an option

Save msly/80d99b06c6143bae8c3a to your computer and use it in GitHub Desktop.
百度开灯问题
// 百度开灯问题
void light() {
vector<bool> vec(100, true);
for (int i=1; i<101; ++i) {
for (int j=0; j<vec.size(); j=j+i+1) {
vec[j] = !vec[j];
}
}
for (int i=0; i<vec.size(); ++i) {
if (vec[i]) {
cout << i << endl;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment