Codeforces Round #396(Div. 2) A. Mahmoud and Longest Uncommon Subsequence

【题意概述】

  找两个字符串的最长不公共子串。

【题目分析】

  两个字符串的最长不公共子串就应该是其中一个字符串本身,那么判断两个字符串是否相等,如果相等,那么肯定没有公共子串,输出“-1”.否则就是两个字符串中长的最长的长度。

【AC】

1 #include<bits/stdc++.h>
2 using namespace std;
3 int main() {
4     char str1[100005],str2[100005];
5     scanf("%s%s",str1,str2);
6     if(strcmp(str1,str2) == 0 ) printf("-1
");
7     else printf("%d
",max(strlen(str1),strlen(str2)));
8     return 0;
9 }