CF379D.New Year Letter

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

许多国家都有在新年或圣诞节给圣诞老人写信并附上礼物愿望清单的传统。瓦夏是一名普通的程序员男孩。像所有普通男孩一样,他将在除夕夜给圣诞老人写这封信(我们俄罗斯人实际上是在新年而非圣诞节期待圣诞老人的到来)。

瓦夏构思了一套写信时遵循的算法。首先,他选择两个仅由大写英文字母组成的字符串 s1s_1 和 s2s_2。然后,男孩利用递推公式 sn=sn−2+sn−1s_n = s_{n-2} + s_{n-1} 构造字符串 sks_k,其中运算符 '+' 表示字符串的连接(即按给定顺序依次拼接)。接着,瓦夏将字符串 sks_k 写在一张纸上,装入信封,并寄给圣诞老人。

瓦夏深信:若最终得到的字符串 sks_k 中恰好包含 xx 个子串 "AC"(这个缩写让他联想到已通过的编程题目),圣诞老人就会送给他最棒的礼物。此外,瓦夏决定字符串 s1s_1 的长度必须为 nn,而字符串 s2s_2 的长度必须为 mm。除此之外,瓦夏尚未做其他任何决定。

目前瓦夏有紧急的新年事务要处理,因此他请你帮他选出符合上述要求的两个字符串 s1s_1 和 s2s_2。请帮助瓦夏。

输入格式

The first line contains four integers k, x, n, m (3 ≤ k ≤ 50; 0 ≤ x ≤ 109; 1 ≤ n, m ≤ 100).

第一行包含四个整数 kk、xx、nn、mm(3 ≤ k ≤ 503 \le k \le 50;0 ≤ x ≤ 1090 \le x \le 10^9;1 ≤ n, m ≤ 1001 \le n, m \le 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.

第一行输出字符串 s1s_1,它由 nn 个大写英文字母组成;
第二行输出字符串 s2s_2,它由 mm 个大写英文字母组成。
若存在多组满足条件的字符串,输出任意一组即可。

如果不存在满足要求的字符串对,则输出 "Happy new year!"(不带引号)。

输入输出样例

  • 输入#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!

输入解题思路,AI测评打分。不知道怎么写?

首页