题目:
S is a string of length n. S consists of lowercase English alphabets.
Your task is to count the number of different S with the minimum number of distinct sub-palindromes. Sub-palindrome is a palindromic substring.
Two sub-palindromes u and v are distinct if their lengths are different or for some i (0≤i≤length), ui≠vi. For example, string “aaaa” contains only 4 distinct sub-palindromes which are “a”, “aa”, “aaa” and “aaaa”.
题目大意:求用最少的不同子回文串构成不同的S的字符串的数量,其中,S由小写英文字母组成,子回文串是回文串的子串
思路:
代码
直接switch相应输出即可
#include <iostream>
using namespace std;
int main()
{
int t;
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
while(cin>>t)
while(t--)
{
int n;
cin>>n;
switch(n)
{
case 1: cout<<26<<endl;break;
case 2: cout<<676<<endl;break;
case 3 : cout<<17576<<endl; break;
default : cout<<15600<<endl;
}
}
return 0;
}
本文地址:https://blog.csdn.net/world_started/article/details/107504253
如对本文有疑问, 点击进行留言回复!!
LongClick原理、上下文菜单原理、EditText长按弹窗原理、WebView长按弹窗自定义、修复WebView全选重复bug ———————————————— 版权声明:本文为CSDN博主「
JobScheduler 实现 特定时间,特定条件(系统空闲,电池电量,磁盘空间 ……)下执行任务
温习Android基础知识——《第一行代码(第三版)》读书笔记 Chapter 10 Service
网友评论