zoukankan      html  css  js  c++  java
  • Strings in the Pocket(马拉车+字符串判断)

    题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=6012
    BaoBao has just found two strings s and in his left pocket, where indicates the -th character in string , and indicates the -th character in string .

    As BaoBao is bored, he decides to select a substring of and reverse it. Formally speaking, he can select two integers and such that and change the string to .

    In how many ways can BaoBao change to using the above operation exactly once? Let be an operation which reverses the substring , and be an operation which reverses the substring . These two operations are considered different, if or .

    Input
    There are multiple test cases. The first line of the input contains an integer , indicating the number of test cases. For each test case:

    The first line contains a string (), while the second line contains another string (). Both strings are composed of lower-cased English letters.

    It's guaranteed that the sum of of all test cases will not exceed .

    Output
    For each test case output one line containing one integer, indicating the answer.

    Sample Input
    2
    abcbcdcbd
    abcdcbcbd
    abc
    abc
    Sample Output
    3
    3
    Hint
    For the first sample test case, BaoBao can do one of the following three operations: (2, 8), (3, 7) or (4, 6).

    For the second sample test case, BaoBao can do one of the following three operations: (1, 1), (2, 2) or (3, 3).

    题意就是,a要变成b,可以有多少种逆转做法;

    分两种情况,1,如果两个相同,用马拉车求回文串数量就好,开longlong

    2.找出不同的点坐标,然后看看这两个点坐标之间是不是逆转后相等,不是输出0,是的话,在往两边找出有多少种做法;

    。。不知道为什么错了,换板子

  • 相关阅读:
    ES6 对Math对象的扩展
    ES6 对Number的扩展
    monolog 应该是世界上最好的日志插件了
    ES6 解构赋值的常见用途,很强大
    ES6 对象的解构赋值
    ES6 数组的解构赋值
    ES6 const
    laravel相关插件
    c++ 库 boost安装
    Eclipse ftp插件
  • 原文地址:https://www.cnblogs.com/wzl19981116/p/10797738.html
Copyright © 2011-2022 走看看