A9338 | New Year Letter
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Many countries have such a New Year or Christmas tradition as writing a letter to Santa including a wish list for presents. Vasya is an ordinary programmer boy. Like all ordinary boys, he is going to write the letter to Santa on the New Year Eve (we Russians actually expect Santa for the New Year, not for Christmas).
Vasya has come up with an algorithm he will follow while writing a letter. First he chooses two strings, $s_{1}$ anf $s_{2}$ , consisting of uppercase English letters. Then the boy makes string $s_{k}$ , using a recurrent equation $s_{n}=s_{n-2}+s_{n-1}$ , operation '+' means a concatenation (that is, the sequential record) of strings in the given order. Then Vasya writes down string $s_{k}$ on a piece of paper, puts it in the envelope and sends in to Santa.
Vasya is absolutely sure that Santa will bring him the best present if the resulting string $s_{k}$ has exactly $x$ occurrences of substring AC (the short-cut reminds him оf accepted problems). Besides, Vasya decided that string $s_{1}$ should have length $n$ , and string $s_{2}$ should have length $m$ . Vasya hasn't decided anything else.
At the moment Vasya's got urgent New Year business, so he asks you to choose two strings for him, $s_{1}$ and $s_{2}$ in the required manner. Help Vasya.
Vasya has come up with an algorithm he will follow while writing a letter. First he chooses two strings, $s_{1}$ anf $s_{2}$ , consisting of uppercase English letters. Then the boy makes string $s_{k}$ , using a recurrent equation $s_{n}=s_{n-2}+s_{n-1}$ , operation '+' means a concatenation (that is, the sequential record) of strings in the given order. Then Vasya writes down string $s_{k}$ on a piece of paper, puts it in the envelope and sends in to Santa.
Vasya is absolutely sure that Santa will bring him the best present if the resulting string $s_{k}$ has exactly $x$ occurrences of substring AC (the short-cut reminds him оf accepted problems). Besides, Vasya decided that string $s_{1}$ should have length $n$ , and string $s_{2}$ should have length $m$ . Vasya hasn't decided anything else.
At the moment Vasya's got urgent New Year business, so he asks you to choose two strings for him, $s_{1}$ and $s_{2}$ in the required manner. Help Vasya.
输入格式
The first line contains four integers $k,x,n,m$ $(3<=k<=50; 0<=x<=10^{9}; 1<=n,m<=100)$ .
输出格式
In the first line print string $s_{1}$ , consisting of $n$ uppercase English letters. In the second line print string $s_{2}$ , consisting of $m$ uppercase English letters. If there are multiple valid strings, print any of them.
If the required pair of strings doesn't exist, print "Happy new year!" without the quotes.
If the required pair of strings doesn't exist, print "Happy new year!" without the quotes.
输入输出样例
输入 #1
3 2 2 2
输出 #1
AC AC
输入 #2
3 3 2 2
输出 #2
Happy new year!
输入 #3
3 0 2 2
输出 #3
AA AA
输入 #4
4 3 2 1
输出 #4
Happy new year!
输入 #5
4 2 2 1
输出 #5
Happy new year!
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted