两个串拼接的时候前一个串尾为A 后一个串头为C才可以多一个AC
所以考虑两个串的首是否为C 尾是否为C
状态压缩用4个位表示这个东西
然后枚举两个串一开始有的AC数 然后暴力check一下
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <stack>
#include <cstring>
#include <cmath>
#include <vector>
#include <ctime>
#include <bitset>
using namespace std;
#define pb push_back
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d%d",&n,&m)
#define sddd(n,m,k) scanf("%d%d%d",&n,&m,&k)
#define sld(n) scanf("%lld",&n)
#define sldd(n,m) scanf("%lld%lld",&n,&m)
#define slddd(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define sf(n) scanf("%lf",&n)
#define sff(n,m) scanf("%lf%lf",&n,&m)
#define sfff(n,m,k) scanf("%lf%lf%lf",&n,&m,&k)
#define ss(str) scanf("%s",str)
#define ans() printf("%d",ans)
#define ansn() printf("%d\n",ans)
#define anss() printf("%d ",ans)
#define lans() printf("%lld",ans)
#define lanss() printf("%lld ",ans)
#define lansn() printf("%lld\n",ans)
#define fansn() printf("%.10f\n",ans)
#define r0(i,n) for(int i=0;i<(n);++i)
#define r1(i,e) for(int i=1;i<=e;++i)
#define rn(i,e) for(int i=e;i>=1;--i)
#define rsz(i,v) for(int i=0;i<(int)v.size();++i)
#define szz(x) ((int)x.size())
#define mst(abc,bca) memset(abc,bca,sizeof abc)
#define lowbit(a) (a&(-a))
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp make_pair
#define lrt rt<<1
#define rrt rt<<1|1
#define X first
#define Y second
#define PI (acos(-1.0))
#define sqr(a) ((a)*(a))
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1000000000+7;
const double eps=1e-9;
const int inf=0x3f3f3f3f;
const ll infl = 10000000000000000;
const int maxn= 1000+10;
const int maxm = 400000+10;
//Pretests passed
int in(int &ret)
{
char c;
int sgn ;
if(c=getchar(),c==EOF)return -1;
while(c!='-'&&(c<'0'||c>'9'))c=getchar();
sgn = (c=='-')?-1:1;
ret = (c=='-')?0:(c-'0');
while(c=getchar(),c>='0'&&c<='9')ret = ret*10+(c-'0');
ret *=sgn;
return 1;
}
int k,x,n,m;
ll cnt(int k,ll ac,ll bc,bool as,bool ae,bool bs,bool be)
{
if(k==2)return bc;
return cnt(k-1,bc,ac+bc+(ae*bs),bs,be,as,be);
}
void out(int n,int c,bool s,bool e)
{
string str;
str.resize(n);
int i = 0;
if(s)str[i++] = 'C';
if(e)str[--n] = 'A';
while(c--)str[i++] = 'A',str[i++] = 'C';
while(i<n)str[i++] = 'X';
cout<<str<<endl;
}
bool check(ll ac,ll bc,bool as,bool ae,bool bs,bool be)
{
if(2*ac+as+ae>n)return 0;
if(2*bc+bs+be>m)return 0;
if(cnt(k,ac,bc,as,ae,bs,be)==x)
{
out(n,ac,as,ae);
out(m,bc,bs,be);
return 1;
}
return 0;
}
int main()
{
#ifdef LOCAL
freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
#endif // LOCAL
sdd(k,x);
sdd(n,m);
for(int i=0;i<=2*n;++i)
{
for(int j = 0;j<=2*m;++j)
{
for(int k = 0;k<16;++k)
{
if(check(i,j,k&1,1&(k>>1),1&(k>>2),1&(k>>3)))return 0;
}
}
}
puts("Happy new year!");
return 0;
}