Skip to content

Instantly share code, notes, and snippets.

@takageymt
Created October 29, 2016 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takageymt/cb238f95cf17a9c3205ec80acf1006d4 to your computer and use it in GitHub Desktop.
Save takageymt/cb238f95cf17a9c3205ec80acf1006d4 to your computer and use it in GitHub Desktop.
誤読したまま書いたコード
string isSquareFree(string s) {
for(int i = 1; i <= s.size()/2; i++) {
for(int j = 0; i + j <= s.size(); j++) {
string t = s.substr(j, i);
for(int k = j+i; i + k <= s.size(); k++) {
if(t == s.substr(k, i)) return "non square-free";
}
}
}
return "square-free";
}
@takageymt
Copy link
Author

commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment