// Note: you must understand the meaning of the question: instead of finding the same character from the two strings, you can find it in the process of comparing strings one by one! # Include <iostream> # include <string> # include <algorithm> using namespace STD; int gcd (int A, int B) {while (B %) {int T = A; A = B % A; B = T;} return a;} int main () {int I, J, K, len1, len2, common, slen, Max; string str1, str2, TMP; while (CIN> str1) {If (str1 = "-1") break; common = 0; CIN> str2; TMP = str2; len1 = str1.length (); len2 = str2.length (); for (I = 0; I <len1; ++ I) {for (j = 0; j <len2; ++ J) {max = 0; For (INT I1 = I, J1 = J; I1 <len1 & J1 <len2; ++ I1, ++ J1) if (str1 [I1] = str2 [J1]) + + Max; If (common <max) Common = max ;}} slen = len1 + len2; if (Common = 0) cout <"appx (" <str1 <"," <TMP <") =" <0 <Endl; else {int num = gcd (Common * 2, slen); If (slen = Common * 2) cout <"appx (" <str1 <", "<TMP <") = "<1 <Endl; else cout <" appx ("<str1 <", "<TMP <") = "<Common * 2/num <"/"<slen/num <Endl ;}} system (" pause ");} /* car cartturkey chickenmoney povertyrough peskya ameet eathappy play-1 */