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;
    }
    
  • 相关阅读:
    数据类型的总结
    typeof加括号和不加括号的区别
    排序
    数据类型分为哪两类
    css中需要更小的字体如何实现
    一些细节注意点
    数值转换题
    如何用分支结构计算年份
    Scout YYF I
    D. AND, OR and square sum
  • 原文地址:https://www.cnblogs.com/Farrell-12138/p/13355186.html
Copyright © 2011-2022 走看看