A13683 | Poman Numbers
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You've got a string $S$ consisting of $n$ lowercase English letters from your friend. It turned out that this is a number written in poman numerals. The poman numeral system is long forgotten. All that's left is the algorithm to transform number from poman numerals to the numeral system familiar to us. Characters of $S$ are numbered from $1$ to $n$ from left to right. Let's denote the value of $S$ as $f(S)$ , it is defined as follows:
- If $|S| > 1$ , an arbitrary integer $m$ ( $1 \le m < |S|$ ) is chosen, and it is defined that $f(S) = -f(S[1, m]) + f(S[m + 1, |S|])$ , where $S[l, r]$ denotes the substring of $S$ from the $l$ -th to the $r$ -th position, inclusively.
- Otherwise $S = c$ , where $c$ is some English letter. Then $f(S) = 2^{pos(c)}$ , where $pos(c)$ is the position of letter $c$ in the alphabet ( $pos($ a $) = 0$ , $pos($ z $) = 25$ ).
Note that $m$ is chosen independently on each step.
Your friend thinks it is possible to get $f(S) = T$ by choosing the right $m$ on every step. Is he right?
- If $|S| > 1$ , an arbitrary integer $m$ ( $1 \le m < |S|$ ) is chosen, and it is defined that $f(S) = -f(S[1, m]) + f(S[m + 1, |S|])$ , where $S[l, r]$ denotes the substring of $S$ from the $l$ -th to the $r$ -th position, inclusively.
- Otherwise $S = c$ , where $c$ is some English letter. Then $f(S) = 2^{pos(c)}$ , where $pos(c)$ is the position of letter $c$ in the alphabet ( $pos($ a $) = 0$ , $pos($ z $) = 25$ ).
Note that $m$ is chosen independently on each step.
Your friend thinks it is possible to get $f(S) = T$ by choosing the right $m$ on every step. Is he right?
输入格式
The first line contains two integers $n$ and $T$ ( $2 \leq n \leq 10^5$ , $-10^{15} \leq T \leq 10^{15}$ ).
The second line contains a string $S$ consisting of $n$ lowercase English letters.
The second line contains a string $S$ consisting of $n$ lowercase English letters.
输出格式
Print "Yes" if it is possible to get the desired value. Otherwise, print "No".
You can print each letter in any case (upper or lower).
You can print each letter in any case (upper or lower).
输入输出样例
输入 #1
2 -1 ba
输出 #1
Yes
输入 #2
3 -7 abc
输出 #2
No
输入 #3
7 -475391 qohshra
输出 #3
Yes
In the second example, you cannot get $-7$ . But you can get $1$ , for example, as follows:
1. First choose $m = 1$ , then $f($ abc $) = -f($ a $) + f($ bc $)$
2. $f($ a $) = 2^0 = 1$
3. $f($ bc $) = -f($ b $) + f($ c $) = -2^1 + 2^2 = 2$
4. In the end $f($ abc $) = -1 + 2 = 1$
1. First choose $m = 1$ , then $f($ abc $) = -f($ a $) + f($ bc $)$
2. $f($ a $) = 2^0 = 1$
3. $f($ bc $) = -f($ b $) + f($ c $) = -2^1 + 2^2 = 2$
4. In the end $f($ abc $) = -1 + 2 = 1$
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted