AtCoder Beginner Contest 242
比赛链接
AtCoder Beginner Contest 242
D - ABC Transform
Problem Statement
You are given a string S consisting of A, B, C.
Let
:=S. For let
be the result of simultaneously replacing the characters of
as follows: A → BC
, B → CA
, C → AB
.
Answer queries. The i-th query is as follows.
Print the ki-th character from the beginning of .
Constraints
- is a string of length between and (inclusive) consisting of .
- $0≤t_i≤10^
- $1≤k_i≤min(10^18, the length of S^{(t_i)})
- $Q,t_i ,k_i are integers.
Input
Input is given from Standard Input in the following format:
Output
Process the queries in ascending order of index, that is, in the given order. Each answer should be followed by a newline.
Sample Input 1
Sample Output 1
Sample Input 2
Sample Output 2
解题思路
思维,递归
考虑当前字符是由前面那个字符转移过来的,相当于一棵二叉树, 每次找根节点,当 为 时即由最开始的 转移过来的,且转移时是以循环转移的
- 时间复杂度:
代码
E - (∀x∀)
Problem Statement
Solve the following problem for test cases.
Given an integer and a string , find the number of strings that satisfy all of the conditions below, modulo 998244353 .
- is a string of length consisting of uppercase English letters.
- is a palindrome.
- in lexicographical order.
-
- That is, or is lexicographically smaller than .
Constraints
- is an integer between 1 and (inclusive).
- In a single input, the sum of over the test cases is at most .
- is a string of length consisting of uppercase English letters.
Input
Input is given from Standard Input in the following format:
case
case
case
Here, case represents the -th test case.
Each test case is in the following format:
Output
Print lines. The -th line should contain the answer for the -th test case as an integer.
Sample Input 1
Sample Output 1
This input contains five test cases.
Test case #1:
The 24 strings satisfying the conditions are AAA, ABA, ACA, ..., AXA.
Test case #2:
may not be a palindrome.
Test case #3:
Be sure to find the count modulo
解题思路
思维
找出前半部分,小于前半部分的回文串肯定都是满足条件的,这里的 相当于十进制的 ,而对于长度为奇数的情况特判一下即可
- 时间复杂度:
代码
__EOF__

本文链接:https://www.cnblogs.com/zyyun/p/15970367.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!