time limit per test2 seconds

memory limit per test256 megabytes

inputstandard input

outputstandard output

While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab challenged Mahmoud with another problem.

Given two strings a and b, find the length of their longest uncommon subsequence, which is the longest string that is a subsequence of one of them and not a subsequence of the other.

A subsequence of some string is a sequence of characters that appears in the same order in the string, The appearances don’t have to be consecutive, for example, strings “ac”, “bc”, “abc” and “a” are subsequences of string “abc” while strings “abbc” and “acb” are not. The empty string is a subsequence of any string. Any string is a subsequence of itself.

Input

The first line contains string a, and the second line — string b. Both of these strings are non-empty and consist of lowercase letters of English alphabet. The length of each string is not bigger than 105 characters.

Output

If there’s no uncommon subsequence, print “-1”. Otherwise print the length of the longest uncommon subsequence of a and b.

Examples

input

abcd

defgh

output

5

input

a

a

output

-1

Note

In the first example: you can choose “defgh” from string b as it is the longest subsequence of string b that doesn’t appear as a subsequence of string a.

【题目链接】:http://codeforces.com/contest/766/problem/A

【题意】



给你两个串A和B,问你两个串的最长不公共子序列;

【题解】



如果两个串相同;

那么答案就为0;

答案不同的话;

看长度;

直接让长度长的那个串的长度当做答案;

(相同的话任意一个就好)



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int MAXN = 110; string a,b; int main()
{
//freopen("F:\\rush.txt","r",stdin);
cin >> a >> b;
if (a==b)
puts("-1");
else
{
int len1 = a.size(),len2 = b.size();
printf("%d\n",max(len1,len2));
}
return 0;
}

【codeforces 766A】Mahmoud and Longest Uncommon Subsequence的更多相关文章

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

    A. Mahmoud and Longest Uncommon Subsequence 题目连接: http://codeforces.com/contest/766/problem/A Descri ...

  2. Codeforces Round #396 (Div. 2) A - Mahmoud and Longest Uncommon Subsequence B - Mahmoud and a Triangle

    地址:http://codeforces.com/contest/766/problem/A A题: A. Mahmoud and Longest Uncommon Subsequence time ...

  3. 766A Mahmoud and Longest Uncommon Subsequence

    A. Mahmoud and Longest Uncommon Subsequence time limit per test 2 seconds memory limit per test 256 ...

  4. Codeforces766A Mahmoud and Longest Uncommon Subsequence 2017-02-21 13:42 46人阅读 评论(0) 收藏

    A. Mahmoud and Longest Uncommon Subsequence time limit per test 2 seconds memory limit per test 256 ...

  5. 【codeforces 766C】Mahmoud and a Message

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. 【codeforces 766D】Mahmoud and a Dictionary

    time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  7. 【codeforces 766B】Mahmoud and a Triangle

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  8. 【codeforces 766E】Mahmoud and a xor trip

    [题目链接]:http://codeforces.com/contest/766/problem/E [题意] 定义树上任意两点之间的距离为这条简单路径上经过的点; 那些点上的权值的所有异或; 求任意 ...

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

    [题意概述] 找两个字符串的最长不公共子串. [题目分析] 两个字符串的最长不公共子串就应该是其中一个字符串本身,那么判断两个字符串是否相等,如果相等,那么肯定没有公共子串,输出"-1&qu ...

随机推荐

  1. SQLSERVER 时间函数汇总

    1.求当天的年份 (getdate(): 2012/05/08 18:07:26) SELECT YEAR(GETDATE())     --2012 2. 求当天的月份       SELECT M ...

  2. spss命令数据整理中compute与record命令的区别

    spss命令数据整理中compute与record命令的区别 record修改存在的变量,或者生成新的变量 spss变量定义说明 1.Name:变量名,定义规则与其它软件中的雷同,如第一个字符必须为字 ...

  3. 可变参数与foreach 的原理

    曾经写过c++11特性使用,但是这个究竟是什么呢,和其他语言的foreach语句十分相像 函数必须具有在编译时已知的单个返回类型;当编译器可以从上下文中找出它必须是什么时,auto只会使您不必输入它. ...

  4. 【OI】操作树

    操作数,一般用来做那些对数列进行添加.撤销操作的题. 假设一开始有一个空数列,有三个操作 (1)在数列后加一个数 (2)求数列中某位置的值 (3)撤销掉最后进行的若干次操作(1和3) 考虑建一棵树,1 ...

  5. oracle-12333错误

    Errors in file /oracle/OraHome1/admin/hndw/udump/hndw_ora_17941.trc: ORA-00600: internal error code, ...

  6. pl/sql基础知识—定义并使用变量

    n  介绍 在编写pl/sql程序是,可以定义变量和常量:在pl/sql程序中包括有: ①标量类型(scalar) ②复合类型(composite) ③参照类型(reference) ④lob(lar ...

  7. 洛谷 P3951 小凯的疑惑 找规律

    目录 题面 题目链接 题目描述 输入输出格式 输入格式: 输出格式: 输入输出样例 输入样例: 输出样例: 说明 思路 证明 AC代码 include<bits/stdc++.h> 题面 ...

  8. 重磅!容器集群监控利器 阿里云Prometheus 正式免费公测

    Prometheus 作为容器生态下集群监控的首选方案,是一套开源的系统监控报警框架.它启发于 Google 的 borgmon 监控系统,并于 2015 年正式发布.2016 年,Prometheu ...

  9. N!分解素因子及若干问题【转载】

    这里写的非常好http://www.cnblogs.com/openorz/archive/2011/11/14/2248992.html,感谢博主,我这里就直接用了. 将N!表示成 N! = p1^ ...

  10. Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第五章:渲染流水线

    原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第五章:渲染流水线 学习目标 了解几个用以表达真实场景的标志和2D图像 ...