#include<iostream> #include <set> #include <climits> #include <cstring> using namespace std; bool isSubString(string subString, string str) { int subLength = subString.length(); int strLength = str.length(); if(subLength == 0) { return false; } for(int i = 0;i < strLength - subLength;++i) { string sunStringTemp = str.substr(i, subLength); if(sunStringTemp == subString) { return true; } } return false; } int main() { int counter = 0; set<string> vec; string str1, str2; cin >> str1 >> str2; int lengthStr1 = str1.length(); int lengthStr2 = str2.length(); for(int i = 0;i < lengthStr1;++i) { for(int j = 0;j <= lengthStr1 - i;++j) { string subString = str1.substr(i, j); if(isSubString(subString, str2) && (vec.find(subString)==vec.end())) { vec.insert(subString); cout << subString << " "; counter++; } } } cout << endl << counter; return 0; }