2020 Multi-University Training Contest 1 补题

2020 Multi-University Training Contest 1 补题

朝鲜出题,作为新手感觉难度很大。

1001 Avian Darts

待更新

1002 Boring Task

待更新

1003 Cookies

待更新

1004 Distinct Sub-palindromes

Problem Description

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 u u and v v v are distinct if their lengths are different or for some i i i (0≤ i i i≤length), u i _i i≠v i _i i. For example, string “aaaa” contains only 4 distinct sub-palindromes which are “a”, “aa”, “aaa” and “aaaa”.

翻译

S是一串长度为 n 的字符串。这串字符串仅包括小写英文字母
你的任务就是数出在n长度的不同的字符串中,有着最小不同连续的回文子串数目的字符串有多少个。
就比如 n 为 4 那么字符串可以是 aaaa,他的不同回文子串一共有4种,分别是 a,aa,aaa,aaaa
不同的前缀长度不同或者字符串不相等(即 strcmp( u u u, v v v) != 0,其中 u u u v v v为回文)

Input

The first line contains an integer T T T ( 1 ≤ T ≤ 1 0 5 ) (1≤T≤10^5) (1T105), denoting the number of test cases.
The only line of each test case contains an integer n ( 1 ≤ n ≤ 1 0 9 ) n (1≤n≤10^9) n(1n109).

Output

For each test case, output a single line containing the number of different strings with minimum number of distinct sub-palindromes.
Since the answer can be huge, output it modulo 998244353.

Sample Input

2
1
2

Sample Output

26
676

当n=1时,26种,显而易见
当n=2时,第一位有26种取法,第二位有26种取法(例子 aa:a/aa,ac:a/c)
当n=3时,第一位26,第二位26,第三位26(可重复,aaa,aba,abc 都有3种)
当n=4时,第一位26,第二位26,第三位26,第四位呢?
比如
abca 有 a b c 然后没了。所以这个是最少,这后面都是重复的。并且按照abc的顺序
比如六个
abcabc
和abccba
肯定是abcabc最少
n > = 4 n>=4 n>=4时,数量为 26 ∗ 25 ∗ 24 26*25*24 262524
n < = 3 n<=3 n<=3时,数量为 2 6 n 26^n 26n

代码

#include <iostream>
using namespace std;
long long ppow(long long x,long long y){
    for(long long i=1;i<y;i++){
        x*=26;
    }
    return x;
}
int main(void){
    long long t,n;
    cin >> t;
    while(t--){
        scanf("%d", &n);
        if(n<=3) printf("%lld\n",ppow(26,n));
        else printf("%lld\n",26*25*24);
    }
    return 0;
}

1005 Fibonacci Sum

1006 Finding a MEX

1007 Hunting Monsters

1008 Integral Calculus

1009 Leading Robots

1010 Math is Simple

1011 Minimum Index

1012 Mow

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值