zoukankan      html  css  js  c++  java
  • 杭电多校第一场 —— Distinct Sub-palindromes

    题意:给出一个字符串的长度,要求求出字符串的回文子串数量(不重复)
    思路:写出n = 1, n = 2, n = 3发现规律res = 26^n, 当n >= 4时,res均等于A(3, 26) 选择三个字符进行排列 : "abca", "abcab", "abcabc" …………
    代码():

    #pragma GCC optimize(2)
    #include<bits/stdc++.h>
    #define lowbit(n) n & (-n)
    #define mem(a) memset(a, 0, sizeof(a));
    #define Buff ios::sync_with_stdio(false)
    #define sqr(x) x*x
    #define pb push_back
    #define x first
    #define y second
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    typedef pair<int, int>PII;
    const int mod = 1e9 + 7;
    const double eps = 1e-6;
    const int base = 131;
    const int N = 1e6+7;
    int main()
    {
        int T;
        cin >> T;
        while(T --)
        {
            int n;
            cin >> n;
            if(n == 1)                    cout << 26 <<endl;
            else if(n == 2)               cout << 26 * 26 <<endl;
            else  if(n == 3)              cout << 26 * 26 * 26 <<endl;
            else                          cout << 26 * 25 * 24 << endl;
        }
        return 0;
    }
    
  • 相关阅读:
    Rsync
    SpringCloud-Eureka
    mysql-主从复制
    java中延迟任务的处理方式
    mysql-分组
    rpm相关
    shell中#*,##*,#*,##*,% *,%% *的含义及用法
    cygwin的用途
    cocos2d-lua-win
    ant打包遇到的问题
  • 原文地址:https://www.cnblogs.com/Farrell-12138/p/13355186.html
Copyright © 2011-2022 走看看